editorElement = element
editor = editorElement.getModel()
vimState = editorElement.vimState
- vimState.activateCommandMode()
- vimState.resetCommandMode()
+ vimState.activateNormalMode()
+ vimState.resetNormalMode()
keydown = (key, options={}) ->
options.element ?= editorElement
it "throws away anything written to it", ->
vimState.setRegister('%', "new content")
expect(vimState.getRegister('%').text).toEqual '/Users/atom/known_value.txt'
+
+ describe "the ctrl-r command in insert mode", ->
+ beforeEach ->
+ editor.setText "02\n"
+ editor.setCursorScreenPosition [0, 0]
+ vimState.setRegister('"', text: '345')
+ vimState.setRegister('a', text: 'abc')
+ atom.clipboard.write "clip"
+ keydown 'a'
+ editor.insertText '1'
+
+ it "inserts contents of the unnamed register with \"", ->
+ keydown 'r', ctrl: true
+ keydown '"'
+ expect(editor.getText()).toBe '013452\n'
+
+ describe "when useClipboardAsDefaultRegister enabled", ->
+ it "inserts contents from clipboard with \"", ->
+ atom.config.set 'vim-mode.useClipboardAsDefaultRegister', true
+ keydown 'r', ctrl: true
+ keydown '"'
+ expect(editor.getText()).toBe '01clip2\n'
+
+ it "inserts contents of the 'a' register", ->
+ keydown 'r', ctrl: true
+ keydown 'a'
+ expect(editor.getText()).toBe '01abc2\n'
+
+ it "is cancelled with the escape key", ->
+ keydown 'r', ctrl: true
+ keydown 'escape'
+ expect(editor.getText()).toBe '012\n'
+ expect(vimState.mode).toBe "insert"
+ expect(editor.getCursorScreenPosition()).toEqual [0, 2]