mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Only pass instances of EditSession to CommandInterpreter
This commit is contained in:
@@ -4,6 +4,7 @@ RegexAddress = require './commands/regex-address'
|
||||
CompositeCommand = require './commands/composite-command'
|
||||
PreviewList = require './preview-list'
|
||||
Editor = require 'editor'
|
||||
EditSession = require 'edit-session'
|
||||
{SyntaxError} = require('pegjs').parser
|
||||
_ = require 'underscore'
|
||||
|
||||
@@ -122,7 +123,9 @@ class CommandPanelView extends View
|
||||
@errorMessages.empty()
|
||||
|
||||
try
|
||||
@commandInterpreter.eval(command, rootView.getActivePaneItem()).done ({operationsToPreview, errorMessages}) =>
|
||||
activePaneItem = rootView.getActivePaneItem()
|
||||
editSession = activePaneItem if activePaneItem instanceof EditSession
|
||||
@commandInterpreter.eval(command, editSession).done ({operationsToPreview, errorMessages}) =>
|
||||
@loadingMessage.hide()
|
||||
@history.push(command)
|
||||
@historyIndex = @history.length
|
||||
|
||||
@@ -548,3 +548,10 @@ describe "CommandPanel", ->
|
||||
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'
|
||||
|
||||
describe "when the active pane item is not an EditSession", ->
|
||||
it "doesn't throw an error (regression)", ->
|
||||
rootView.open('binary-file.png')
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
|
||||
expect(-> commandPanel.execute('Xx/sort/')).not.toThrow()
|
||||
|
||||
Reference in New Issue
Block a user