mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 16:09:57 +03:00
Meta-g repeats the last relative address command
Rename repeatLastRelativeAddress to repeatRelativeAddress since it's implied that it's the "last" one.
This commit is contained in:
parent
3bda7c4d3f
commit
7708cf7f33
@ -104,24 +104,24 @@ describe "CommandInterpreter", ->
|
||||
expect(buffer.lineForRow(5)).toBe '!!!!!!current!=!items.shift();'
|
||||
expect(buffer.lineForRow(6)).toBe ' current < pivot ? left.push(current) : right.push(current);'
|
||||
|
||||
describe ".repeatLastRelativeAddress()", ->
|
||||
describe ".repeatRelativeAddress()", ->
|
||||
it "repeats the last search command", ->
|
||||
editor.setCursorScreenPosition([4, 0])
|
||||
|
||||
interpreter.eval(editor, '/current')
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[5,6], [5,13]]
|
||||
|
||||
interpreter.repeatLastRelativeAddress(editor)
|
||||
interpreter.repeatRelativeAddress(editor)
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[6,6], [6,13]]
|
||||
|
||||
interpreter.eval(editor, 's/r/R/g')
|
||||
|
||||
interpreter.repeatLastRelativeAddress(editor)
|
||||
interpreter.repeatRelativeAddress(editor)
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[6,34], [6,41]]
|
||||
|
||||
interpreter.eval(editor, '0')
|
||||
interpreter.eval(editor, '/sort/ s/r/R/') # this contains a substitution... won't be repeated
|
||||
|
||||
interpreter.repeatLastRelativeAddress(editor)
|
||||
interpreter.repeatRelativeAddress(editor)
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[3,31], [3,38]]
|
||||
|
||||
|
@ -33,6 +33,12 @@ describe "CommandPanel", ->
|
||||
expect(commandPanel.editor.buffer.getText()).toBe ''
|
||||
expect(commandPanel.editor.getCursorScreenPosition()).toEqual [0, 0]
|
||||
|
||||
describe "when command-panel:repeat-relative-address is triggered on the root view", ->
|
||||
it "calls .repeatRelativeAddress on the command interpreter with the active editor", ->
|
||||
spyOn(commandPanel.commandInterpreter, 'repeatRelativeAddress')
|
||||
rootView.trigger 'command-panel:repeat-relative-address'
|
||||
expect(commandPanel.commandInterpreter.repeatRelativeAddress).toHaveBeenCalledWith(rootView.activeEditor())
|
||||
|
||||
describe "when esc is pressed in the command panel", ->
|
||||
it "closes the command panel", ->
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
|
@ -11,6 +11,6 @@ class CommandInterpreter
|
||||
@lastRelativeAddress = command if command.isRelativeAddress()
|
||||
command.execute(editor)
|
||||
|
||||
repeatLastRelativeAddress: (editor) ->
|
||||
repeatRelativeAddress: (editor) ->
|
||||
@lastRelativeAddress.execute(editor)
|
||||
|
||||
|
@ -17,8 +17,12 @@ class CommandPanel extends View
|
||||
escape: 'command-panel:toggle'
|
||||
enter: 'command-panel:execute'
|
||||
|
||||
window.keymap.bindKeys '.editor',
|
||||
'meta-g': 'command-panel:repeat-relative-address'
|
||||
|
||||
@rootView.on 'command-panel:toggle', => @toggle()
|
||||
@rootView.on 'command-panel:execute', => @execute()
|
||||
@rootView.on 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
|
||||
@editor.addClass 'single-line'
|
||||
|
||||
@commandInterpreter = new CommandInterpreter()
|
||||
@ -35,4 +39,7 @@ class CommandPanel extends View
|
||||
|
||||
execute: ->
|
||||
@commandInterpreter.eval(@rootView.activeEditor(), @editor.getText())
|
||||
@toggle()
|
||||
@toggle()
|
||||
|
||||
repeatRelativeAddress: ->
|
||||
@commandInterpreter.repeatRelativeAddress(@rootView.activeEditor())
|
||||
|
Loading…
Reference in New Issue
Block a user