From 8a4b5b13bb735a319d243b70e4208ca92100f747 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Wed, 11 Apr 2012 17:42:02 -0600 Subject: [PATCH] Don't close the window when the last editor is closed. Focus the root view instead. --- spec/app/root-view-spec.coffee | 23 ++++++++++++----------- src/app/root-view.coffee | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 8d8df7b1b..00f6d604c 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -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() diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 151809443..76dd18268 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -66,7 +66,7 @@ class RootView extends View if @editors().length @editors()[0].focus() else - window.close() + @focus() setTitle: (title='untitled') -> document.title = title