From 192df9c496cf6aaa194a29d0f45ab992d0f2b620 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 8 Oct 2013 17:01:10 -0700 Subject: [PATCH 1/9] Make each tab have its own editor. Remove the viewsByClassName from the pane. Pane specs are broken. --- src/editor.coffee | 3 --- src/pane.coffee | 24 ++++-------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/editor.coffee b/src/editor.coffee index 5102302a3..09c3fdf1e 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -830,9 +830,6 @@ class Editor extends View getModel: -> @activeEditSession - setModel: (editSession) -> - @edit(editSession) - showBufferConflictAlert: (editSession) -> atom.confirm( editSession.getPath(), diff --git a/src/pane.coffee b/src/pane.coffee index 81f973b7c..1a8473ee0 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -28,7 +28,6 @@ class Pane extends View activeItem: null items: null - viewsByClassName: null # Views with a setModel() method are stored here viewsByItem: null # Views without a setModel() method are stored here # Private: @@ -53,7 +52,6 @@ class Pane extends View return if site is @state.site.id @showItemForUri(newValue) if key is 'activeItemUri' - @viewsByClassName = {} @viewsByItem = new WeakMap() activeItemUri = @state.get('activeItemUri') unless activeItemUri? and @showItemForUri(activeItemUri) @@ -322,16 +320,8 @@ class Pane extends View cleanupItemView: (item) -> if item instanceof $ viewToRemove = item - else - if viewToRemove = @viewsByItem.get(item) - @viewsByItem.delete(item) - else - viewClass = item.getViewClass() - otherItemsForView = @items.filter (i) -> i.getViewClass?() is viewClass - unless otherItemsForView.length - viewToRemove = @viewsByClassName[viewClass.name] - viewToRemove?.setModel(null) - delete @viewsByClassName[viewClass.name] + else if @viewsByItem.get(item) + @viewsByItem.delete(item) if @items.length > 0 if @isMovingItem and item is viewToRemove @@ -350,14 +340,8 @@ class Pane extends View view else viewClass = item.getViewClass() - if view = @viewsByClassName[viewClass.name] - view.setModel(item) - else - view = new viewClass(item) - if _.isFunction(view.setModel) - @viewsByClassName[viewClass.name] = view - else - @viewsByItem.set(item, view) + view = new viewClass(item) + @viewsByItem.set(item, view) view # Private: From 1120a14351ce8d476427661d90c72550cc84149c Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 9 Oct 2013 17:43:20 -0700 Subject: [PATCH 2/9] Fix removal of editors --- spec/pane-spec.coffee | 59 +++++++++++++++++++++---------------------- src/editor.coffee | 3 +++ src/pane.coffee | 11 ++++++-- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 55fa28ddf..7bc8bc7ff 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -94,43 +94,42 @@ describe "Pane", -> expect(editor.activeEditSession).toBe editSession1 describe "when a valid view has already been appended for another item", -> - describe "when the view has a setModel method", -> - it "recycles the existing view by assigning the selected item to it", -> - pane.showItem(editSession1) - pane.showItem(editSession2) - expect(pane.itemViews.find('.editor').length).toBe 1 - editor = pane.activeView - expect(editor.css('display')).toBe '' - expect(editor.activeEditSession).toBe editSession2 + it "multiple views are created for multiple items", -> + pane.showItem(editSession1) + pane.showItem(editSession2) + expect(pane.itemViews.find('.editor').length).toBe 2 + editor = pane.activeView + expect(editor.css('display')).toBe '' + expect(editor.activeEditSession).toBe editSession2 - describe "when the view does not have a setModel method", -> - it "creates a new view with the item", -> - initialViewCount = pane.itemViews.find('.test-view').length + it "creates a new view with the item", -> + initialViewCount = pane.itemViews.find('.test-view').length + console.log 'initial', initialViewCount - model1 = - id: 'test-model-1' - text: 'Test Model 1' - serialize: -> {@id, @text} - getViewClass: -> TestView + model1 = + id: 'test-model-1' + text: 'Test Model 1' + serialize: -> {@id, @text} + getViewClass: -> TestView - model2 = - id: 'test-model-2' - text: 'Test Model 2' - serialize: -> {@id, @text} - getViewClass: -> TestView + model2 = + id: 'test-model-2' + text: 'Test Model 2' + serialize: -> {@id, @text} + getViewClass: -> TestView - pane.showItem(model1) - pane.showItem(model2) - expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 2 + pane.showItem(model1) + pane.showItem(model2) + expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 2 - pane.showPreviousItem() - expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 2 + pane.showPreviousItem() + expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 2 - pane.removeItem(model2) - expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 1 + pane.removeItem(model2) + expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 1 - pane.removeItem(model1) - expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + pane.removeItem(model1) + expect(pane.itemViews.find('.test-view').length).toBe initialViewCount describe "when showing a view item", -> it "appends it to the itemViews div if it hasn't already been appended and shows it", -> diff --git a/src/editor.coffee b/src/editor.coffee index 09c3fdf1e..5102302a3 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -830,6 +830,9 @@ class Editor extends View getModel: -> @activeEditSession + setModel: (editSession) -> + @edit(editSession) + showBufferConflictAlert: (editSession) -> atom.confirm( editSession.getPath(), diff --git a/src/pane.coffee b/src/pane.coffee index 1a8473ee0..df3bcf08d 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -320,16 +320,23 @@ class Pane extends View cleanupItemView: (item) -> if item instanceof $ viewToRemove = item - else if @viewsByItem.get(item) + else if viewToRemove = @viewsByItem.get(item) @viewsByItem.delete(item) if @items.length > 0 if @isMovingItem and item is viewToRemove viewToRemove?.detach() + else if @isMovingItem and viewToRemove?.setModel + viewToRemove.setModel(null) # dont want to destroy the model, so set to null + viewToRemove.remove() else viewToRemove?.remove() else - viewToRemove?.detach() if @isMovingItem and item is viewToRemove + if @isMovingItem and item is viewToRemove + viewToRemove?.detach() + else if @isMovingItem and viewToRemove?.setModel + viewToRemove.setModel(null) # dont want to destroy the model, so set to null + @parent().view().removeChild(this, updateState: false) # Private: From 187895a893babc97668b3cbf75744fc2344e1f38 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 9 Oct 2013 17:43:46 -0700 Subject: [PATCH 3/9] I'm not entirely sure why I need this now. It seems there is no editor unless I show the first editSession --- spec/pane-spec.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 7bc8bc7ff..ed8a7587d 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -236,6 +236,7 @@ describe "Pane", -> describe "when the item is a model", -> it "removes the associated view only when all items that require it have been removed", -> + pane.showItem(editSession1) pane.showItem(editSession2) pane.removeItem(editSession2) expect(pane.itemViews.find('.editor')).toExist() From 78f600a7f684ac13058a1419a8ae5721ecc9dc79 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Oct 2013 15:15:01 -0700 Subject: [PATCH 4/9] Upgrade to fuzzy-finder@0.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 00d3e6e23..cda08dabf 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "editor-stats": "0.3.0", "exception-reporting": "0.4.0", "find-and-replace": "0.24.0", - "fuzzy-finder": "0.8.0", + "fuzzy-finder": "0.9.0", "gfm": "0.5.0", "git-diff": "0.5.0", "gists": "0.3.0", From 7db7234fb1729f00591711e68974b5531f352a07 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Oct 2013 15:23:51 -0700 Subject: [PATCH 5/9] fix rootView spec --- spec/root-view-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/root-view-spec.coffee b/spec/root-view-spec.coffee index 94483cb6a..0a5c04536 100644 --- a/spec/root-view-spec.coffee +++ b/spec/root-view-spec.coffee @@ -33,7 +33,7 @@ describe "RootView", -> editor1 = rootView.getActiveView() buffer = editor1.getBuffer() editor1.splitRight() - expect(rootView.getActiveView()).toBe rootView.getEditors()[1] + expect(rootView.getActiveView()).toBe rootView.getEditors()[2] refreshRootViewAndProject() From 142654b77ca0f5266e83a67e2c4da2597c133115 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Oct 2013 15:29:49 -0700 Subject: [PATCH 6/9] Upgrade to fnr@0.24.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cda08dabf..a43caab12 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "command-palette": "0.4.0", "editor-stats": "0.3.0", "exception-reporting": "0.4.0", - "find-and-replace": "0.24.0", + "find-and-replace": "0.24.1", "fuzzy-finder": "0.9.0", "gfm": "0.5.0", "git-diff": "0.5.0", From 338eb5a87166d08550c46cf1721ef3907c979b67 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Oct 2013 15:45:54 -0700 Subject: [PATCH 7/9] Upgrade fnr --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a43caab12..2c6bf83f5 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "command-palette": "0.4.0", "editor-stats": "0.3.0", "exception-reporting": "0.4.0", - "find-and-replace": "0.24.1", + "find-and-replace": "0.24.2", "fuzzy-finder": "0.9.0", "gfm": "0.5.0", "git-diff": "0.5.0", From 730cd8680ecb55b7fc5d1a7fdbe3878f382ba359 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Oct 2013 16:43:39 -0700 Subject: [PATCH 8/9] Upgrade git-diff for fixing --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c6bf83f5..8f95ed3c7 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "find-and-replace": "0.24.2", "fuzzy-finder": "0.9.0", "gfm": "0.5.0", - "git-diff": "0.5.0", + "git-diff": "0.6.1", "gists": "0.3.0", "github-sign-in": "0.7.0", "go-to-line": "0.4.0", From dafa1ab0a8e7e5b66c7fbab74e250233ef85463b Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Thu, 10 Oct 2013 16:59:30 -0700 Subject: [PATCH 9/9] UPgrade status bar --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f95ed3c7..8d57a8587 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "settings-view": "0.27.0", "snippets": "0.6.0", "spell-check": "0.6.0", - "status-bar": "0.9.0", + "status-bar": "0.10.1", "symbols-view": "0.8.0", "tabs": "0.5.0", "terminal": "0.10.0",