Only pass instances of EditSession to CommandInterpreter

This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-04-26 14:52:34 -07:00
parent 7fdfd71382
commit 0e3f9297fb
2 changed files with 11 additions and 1 deletions

View File

@@ -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

View File

@@ -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()