]> git.r.bdr.sh - rbdr/dotfiles/blobdiff - atom/packages/vim-mode/spec/prefixes-spec.coffee
Adds yajs submodule
[rbdr/dotfiles] / atom / packages / vim-mode / spec / prefixes-spec.coffee
index e782d20ad096640e431f6e2e6a0b6914030aaf23..71c4a12c040eea856cac14081ed2980ed22e7911 100644 (file)
@@ -11,8 +11,8 @@ describe "Prefixes", ->
       editorElement = element
       editor = editorElement.getModel()
       vimState = editorElement.vimState
-      vimState.activateCommandMode()
-      vimState.resetCommandMode()
+      vimState.activateNormalMode()
+      vimState.resetNormalMode()
 
   keydown = (key, options={}) ->
     options.element ?= editorElement
@@ -146,3 +146,37 @@ describe "Prefixes", ->
         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]