mirror of
https://github.com/atom/atom.git
synced 2026-01-25 23:08:18 -05:00
Select path when collapsed via command
This commit is contained in:
@@ -15,16 +15,20 @@ class PathView extends View
|
||||
for operation in operations
|
||||
@subview "operation#{operation.index}", new OperationView({operation, previewList})
|
||||
|
||||
initialize: ({previewList}) ->
|
||||
initialize: ({@previewList}) ->
|
||||
@on 'mousedown', @onPathSelected
|
||||
previewList.command 'command-panel:collapse-result', =>
|
||||
@collapse(true) if @isSelected()
|
||||
previewList.command 'command-panel:expand-result', =>
|
||||
@previewList.command 'command-panel:collapse-result', =>
|
||||
@collapse(true, true) if @isSelected()
|
||||
@previewList.command 'command-panel:expand-result', =>
|
||||
@expand(true) if @isSelected()
|
||||
|
||||
isSelected: ->
|
||||
@hasClass('selected') or @find('.selected').length
|
||||
|
||||
setSelected: ->
|
||||
@previewList.find('.selected').removeClass('selected')
|
||||
@addClass('selected')
|
||||
|
||||
onPathSelected: (event) =>
|
||||
e = $(event.target)
|
||||
e = e.parent() if e.parent().hasClass 'path'
|
||||
@@ -43,9 +47,12 @@ class PathView extends View
|
||||
@matches.show()
|
||||
@removeClass 'is-collapsed'
|
||||
|
||||
collapse: (animate=false) ->
|
||||
collapse: (animate=false, select=false) ->
|
||||
if animate
|
||||
@matches.hide 100, => @addClass 'is-collapsed'
|
||||
@matches.hide 100, =>
|
||||
@addClass 'is-collapsed'
|
||||
@setSelected() if select
|
||||
else
|
||||
@matches.hide()
|
||||
@addClass 'is-collapsed'
|
||||
@setSelected() if select
|
||||
|
||||
@@ -480,10 +480,12 @@ describe "CommandPanel", ->
|
||||
expect(previewList.find('li.path:first-child ul.matches')).toBeVisible()
|
||||
|
||||
describe "when command-panel:collapse-result and command-panel:expand-result are triggered", ->
|
||||
it "collapses and expands the path of the selection", ->
|
||||
it "collapses and selects the path, and then expands the selected path", ->
|
||||
rootView.attachToDom()
|
||||
expect(previewList.find('li.path:first-child ul.matches')).toBeVisible()
|
||||
previewList.trigger 'command-panel:collapse-result'
|
||||
expect(previewList.find('li.path:first-child ul.matches')).toBeHidden()
|
||||
expect(previewList.find('li.path:first-child')).toHaveClass 'selected'
|
||||
previewList.trigger 'command-panel:expand-result'
|
||||
expect(previewList.find('li.path:first-child ul.matches')).toBeVisible()
|
||||
expect(previewList.find('li.path:first-child')).toHaveClass 'selected'
|
||||
|
||||
Reference in New Issue
Block a user