mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Destroy preview list's previous operations when populating new ones
This commit is contained in:
@@ -241,6 +241,10 @@ describe "CommandPanel", ->
|
||||
rootView.trigger 'command-panel:toggle-preview' # ensure we can close panel without problems
|
||||
expect(commandPanel).toBeHidden()
|
||||
|
||||
it "destroys previously previewed operations if there are any", ->
|
||||
waitsForPromise -> commandPanel.execute('X x/b+/')
|
||||
# there shouldn't be any dangling operations after this
|
||||
|
||||
describe "if the command is malformed", ->
|
||||
it "adds and removes an error class to the command panel and does not close it", ->
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
|
||||
@@ -15,7 +15,9 @@ class PreviewList extends View
|
||||
|
||||
hasOperations: -> @operations?
|
||||
|
||||
populate: (@operations) ->
|
||||
populate: (operations) ->
|
||||
@destroyOperations() if @operations
|
||||
@operations = operations
|
||||
@empty()
|
||||
@html $$$ ->
|
||||
for operation in operations
|
||||
@@ -28,7 +30,6 @@ class PreviewList extends View
|
||||
@span suffix
|
||||
|
||||
@setSelectedOperationIndex(0)
|
||||
|
||||
@show()
|
||||
|
||||
selectNextOperation: ->
|
||||
@@ -55,6 +56,10 @@ class PreviewList extends View
|
||||
getOperations: ->
|
||||
new Array(@operations...)
|
||||
|
||||
destroyOperations: ->
|
||||
operation.destroy() for operation in @getOperations()
|
||||
@operations = null
|
||||
|
||||
getSelectedOperation: ->
|
||||
@operations[@selectedOperationIndex]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user