Don't close the window when the last editor is closed. Focus the root view instead.

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-04-11 17:42:02 -06:00
parent ceaad1798b
commit 8a4b5b13bb
2 changed files with 13 additions and 12 deletions

View File

@@ -290,7 +290,7 @@ describe "RootView", ->
expect(editor5.outerHeight()).toBe Math.floor(1/3 * rootView.height())
describe "when close is triggered on an editor pane", ->
it "adjusts the layout, focuses the next most-recently active editor, and closes the window when there are no remaining editors", ->
it "adjusts the layout, focuses the next most-recently active editor, and focuses the RootView when there are no remaining editors", ->
spyOn(window, 'close')
editor = rootView.find('.editor').view()
editor.trigger 'split-right'
@@ -305,18 +305,19 @@ describe "RootView", ->
expect(editor2.outerWidth()).toBe Math.floor(rootView.width() / 3)
expect(editor3.outerWidth()).toBe Math.floor(rootView.width() / 3)
# editor3.trigger 'close'
# expect(editor1.isFocused).toBeTruthy()
# expect(editor1.outerWidth()).toBe Math.floor(rootView.width() / 2)
# expect(editor2.outerWidth()).toBe Math.floor(rootView.width() / 2)
editor3.trigger 'close'
expect(editor1.isFocused).toBeTruthy()
expect(editor1.outerWidth()).toBe Math.floor(rootView.width() / 2)
expect(editor2.outerWidth()).toBe Math.floor(rootView.width() / 2)
# editor1.trigger 'close'
# expect(editor2.isFocused).toBeTruthy()
# expect(editor2.outerWidth()).toBe Math.floor(rootView.width())
editor1.trigger 'close'
expect(editor2.isFocused).toBeTruthy()
expect(editor2.outerWidth()).toBe Math.floor(rootView.width())
# expect(window.close).not.toHaveBeenCalled()
# editor2.trigger 'close'
# expect(window.close).toHaveBeenCalled()
expect(window.close).not.toHaveBeenCalled()
editor2.trigger 'close'
expect(rootView).toMatchSelector(':focus')
it "removes a containing row if it becomes empty", ->
editor = rootView.find('.editor').view()

View File

@@ -66,7 +66,7 @@ class RootView extends View
if @editors().length
@editors()[0].focus()
else
window.close()
@focus()
setTitle: (title='untitled') ->
document.title = title