File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -205,13 +205,17 @@ class TreeView extends View
205205 when 1
206206 @ selectEntry (entry)
207207 if entry instanceof FileView
208- @openedItem = atom .workspace .open (entry .getPath (), pending : true )
208+ if entry .getPath () is atom .workspace .getActivePaneItem ()? .getPath ? ()
209+ @ focus ()
210+ else
211+ @openedItem = atom .workspace .open (entry .getPath (), pending : true )
209212 else if entry instanceof DirectoryView
210213 entry .toggleExpansion (isRecursive)
211214 when 2
212215 if entry instanceof FileView
213216 @openedItem .then ((item ) -> item .terminatePendingState ? ())
214- @ unfocus ()
217+ unless entry .getPath () is atom .workspace .getActivePaneItem ()? .getPath ? ()
218+ @ unfocus ()
215219 else if entry instanceof DirectoryView
216220 entry .toggleExpansion (isRecursive)
217221
Original file line number Diff line number Diff line change @@ -614,12 +614,18 @@ describe "TreeView", ->
614614 expect (activePaneItem .isPending ()).toBe true
615615
616616 it " terminates pending state on the double-click and focuses file" , ->
617- sampleJs .trigger clickEvent (originalEvent : {detail : 1 })
618617 sampleJs .trigger clickEvent (originalEvent : {detail : 2 })
619618 expect (atom .views .getView (activePaneItem)).toHaveFocus ()
620619 waitsFor ->
621620 activePaneItem .isPending () is false
622621
622+ it " keeps focus on tree-view if the file is the active pane item" , ->
623+ sampleJs .trigger clickEvent (originalEvent : {detail : 1 })
624+ expect (treeView).toHaveFocus ()
625+
626+ sampleJs .trigger clickEvent (originalEvent : {detail : 2 })
627+ expect (treeView).toHaveFocus ()
628+
623629 describe " when a directory is single-clicked" , ->
624630 it " is selected" , ->
625631 subdir = root1 .find (' .directory:first' )
You can’t perform that action at this time.
0 commit comments