mirror of
https://github.com/atom/atom.git
synced 2026-02-17 10:01:25 -05:00
Replace @buffer reference on Editor with @getBuffer method
This commit is contained in:
@@ -52,7 +52,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe "when no text is selected", ->
|
||||
it 'autocompletes word when there is only a prefix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:s:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:s:extra")
|
||||
editor.setCursorBufferPosition([10,7])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -65,7 +65,7 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.matchesList.find('li:eq(1)')).toHaveText('shift')
|
||||
|
||||
it 'autocompletes word when there is only a suffix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:e:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:e:extra")
|
||||
editor.setCursorBufferPosition([10,6])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -77,7 +77,7 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.matchesList.find('li:eq(0)')).toHaveText('while')
|
||||
|
||||
it 'autocompletes word when there is a prefix and suffix', ->
|
||||
editor.buffer.insert([8,43] ,"q")
|
||||
editor.getBuffer().insert([8,43] ,"q")
|
||||
editor.setCursorBufferPosition([8,44])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -97,7 +97,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe "when text is selected", ->
|
||||
it 'autocompletes word when there is only a prefix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:sort:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:sort:extra")
|
||||
editor.setSelectedBufferRange [[10,7], [10,10]]
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -109,7 +109,7 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.matchesList.find('li:eq(0)')).toHaveText('shift')
|
||||
|
||||
it 'autocompletes word when there is only a suffix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:current:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:current:extra")
|
||||
editor.setSelectedBufferRange [[10,6],[10,12]]
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -133,7 +133,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe 'autocomplete:confirm event', ->
|
||||
it 'replaces selection with selected match, moves the cursor to the end of the match, and removes the autocomplete menu', ->
|
||||
editor.buffer.insert([10,0] ,"extra:sort:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:sort:extra")
|
||||
editor.setSelectedBufferRange [[10,7], [10,9]]
|
||||
autocomplete.attach()
|
||||
miniEditor.trigger "autocomplete:confirm"
|
||||
@@ -145,7 +145,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe "when there are no matches", ->
|
||||
it "closes the menu without changing the buffer", ->
|
||||
editor.buffer.insert([10,0] ,"xxx")
|
||||
editor.getBuffer().insert([10,0] ,"xxx")
|
||||
editor.setCursorBufferPosition [10, 3]
|
||||
autocomplete.attach()
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 1
|
||||
@@ -160,7 +160,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe 'autocomplete:cancel event', ->
|
||||
it 'does not replace selection, removes autocomplete view and returns focus to editor', ->
|
||||
editor.buffer.insert([10,0] ,"extra:so:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:so:extra")
|
||||
editor.setSelectedBufferRange [[10,7], [10,8]]
|
||||
originalSelectionBufferRange = editor.getSelection().getBufferRange()
|
||||
|
||||
@@ -173,7 +173,7 @@ describe "Autocomplete", ->
|
||||
expect(editor.find('.autocomplete')).not.toExist()
|
||||
|
||||
it "does not clear out a previously confirmed selection when canceling with an empty list", ->
|
||||
editor.buffer.insert([10, 0], "sort\n")
|
||||
editor.getBuffer().insert([10, 0], "sort\n")
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
|
||||
autocomplete.attach()
|
||||
@@ -187,7 +187,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe 'move-up event', ->
|
||||
it "highlights the previous match and replaces the selection with it", ->
|
||||
editor.buffer.insert([10,0] ,"extra:t:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:t:extra")
|
||||
editor.setCursorBufferPosition([10,6])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -204,7 +204,7 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.find('li:eq(6)')).toHaveClass('selected')
|
||||
|
||||
it "scrolls to the selected match if it is out of view", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
editor.attachToDom()
|
||||
autocomplete.attach()
|
||||
@@ -222,7 +222,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe 'move-down event', ->
|
||||
it "highlights the next match and replaces the selection with it", ->
|
||||
editor.buffer.insert([10,0] ,"extra:s:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:s:extra")
|
||||
editor.setCursorBufferPosition([10,7])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -237,7 +237,7 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.find('li:eq(1)')).not.toHaveClass('selected')
|
||||
|
||||
it "scrolls to the selected match if it is out of view", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
editor.attachToDom()
|
||||
autocomplete.attach()
|
||||
@@ -255,7 +255,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe "when a match is clicked in the match list", ->
|
||||
it "selects and confirms the match", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -268,7 +268,7 @@ describe "Autocomplete", ->
|
||||
expect(editor.lineForBufferRow(10)).toBe matchToSelect.text()
|
||||
|
||||
it "cancels the autocomplete when clicking on the 'No matches found' li", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -281,7 +281,7 @@ describe "Autocomplete", ->
|
||||
describe "when the mini-editor receives keyboard input", ->
|
||||
describe "when text is removed from the mini-editor", ->
|
||||
it "reloads the match list based on the mini-editor's text", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10,0])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -293,7 +293,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe "when the text contains only word characters", ->
|
||||
it "narrows the list of completions with the fuzzy match algorithm", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10,0])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -314,7 +314,7 @@ describe "Autocomplete", ->
|
||||
|
||||
describe "when a non-word character is typed in the mini-editor", ->
|
||||
it "immediately confirms the current completion choice and inserts that character into the buffer", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.getBuffer().insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10,0])
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -339,12 +339,12 @@ describe "Autocomplete", ->
|
||||
describe "when the autocomplete menu is detached", ->
|
||||
it 'updates word list', ->
|
||||
spyOn(autocomplete, 'buildWordList')
|
||||
editor.buffer.change([[0,4],[0,13]], "sauron")
|
||||
editor.getBuffer().change([[0,4],[0,13]], "sauron")
|
||||
expect(autocomplete.buildWordList).toHaveBeenCalled()
|
||||
|
||||
describe "when the autocomplete menu is attached and the change was caused by autocomplete itself", ->
|
||||
it 'does not rebuild the word list', ->
|
||||
editor.buffer.insert([10,0] ,"extra:s:extra")
|
||||
editor.getBuffer().insert([10,0] ,"extra:s:extra")
|
||||
|
||||
spyOn(autocomplete, 'buildWordList')
|
||||
editor.setCursorBufferPosition([10,7])
|
||||
@@ -364,7 +364,7 @@ describe "Autocomplete", ->
|
||||
expect(wordList).toContain "Some"
|
||||
|
||||
it 'stops listening to previous buffers change events', ->
|
||||
previousBuffer = editor.buffer
|
||||
previousBuffer = editor.getBuffer()
|
||||
editor.edit(fixturesProject.open('sample.txt'))
|
||||
spyOn(autocomplete, "buildWordList")
|
||||
|
||||
@@ -375,12 +375,12 @@ describe "Autocomplete", ->
|
||||
describe 'when the editor is removed', ->
|
||||
it 'removes event listeners from its buffer', ->
|
||||
spyOn(autocomplete, 'buildWordList').andCallThrough()
|
||||
editor.buffer.insert([0,0], "s")
|
||||
editor.getBuffer().insert([0,0], "s")
|
||||
expect(autocomplete.buildWordList).toHaveBeenCalled()
|
||||
|
||||
autocomplete.buildWordList.reset()
|
||||
editor.remove()
|
||||
editor.buffer.insert([0,0], "s")
|
||||
editor.getBuffer().insert([0,0], "s")
|
||||
expect(autocomplete.buildWordList).not.toHaveBeenCalled()
|
||||
|
||||
describe ".attach()", ->
|
||||
@@ -416,10 +416,10 @@ describe "Autocomplete", ->
|
||||
describe ".detach()", ->
|
||||
it "clears the mini-editor and unbinds autocomplete event handlers for move-up and move-down", ->
|
||||
autocomplete.attach()
|
||||
miniEditor.buffer.setText('foo')
|
||||
miniEditor.getBuffer().setText('foo')
|
||||
|
||||
autocomplete.detach()
|
||||
expect(miniEditor.buffer.getText()).toBe ''
|
||||
expect(miniEditor.getBuffer().getText()).toBe ''
|
||||
|
||||
editor.trigger 'move-down'
|
||||
expect(editor.getCursorBufferPosition().row).toBe 1
|
||||
|
||||
@@ -49,7 +49,7 @@ describe "CommandPanel", ->
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
expect(rootView.find('.command-panel').view()).toBe commandPanel
|
||||
expect(commandPanel.miniEditor.isFocused).toBeTruthy()
|
||||
expect(commandPanel.miniEditor.buffer.getText()).toBe ''
|
||||
expect(commandPanel.miniEditor.getBuffer().getText()).toBe ''
|
||||
expect(commandPanel.miniEditor.getCursorScreenPosition()).toEqual [0, 0]
|
||||
|
||||
describe "when command-panel:repeat-relative-address is triggered on the root view", ->
|
||||
|
||||
@@ -71,14 +71,14 @@ describe 'FuzzyFinder', ->
|
||||
selectedLi = finder.find('li:eq(1)')
|
||||
|
||||
expectedPath = rootView.project.resolve(selectedLi.text())
|
||||
expect(editor1.buffer.getPath()).not.toBe expectedPath
|
||||
expect(editor2.buffer.getPath()).not.toBe expectedPath
|
||||
expect(editor1.getBuffer().getPath()).not.toBe expectedPath
|
||||
expect(editor2.getBuffer().getPath()).not.toBe expectedPath
|
||||
|
||||
finder.trigger 'fuzzy-finder:select-path'
|
||||
|
||||
expect(finder.hasParent()).toBeFalsy()
|
||||
expect(editor1.buffer.getPath()).not.toBe expectedPath
|
||||
expect(editor2.buffer.getPath()).toBe expectedPath
|
||||
expect(editor1.getBuffer().getPath()).not.toBe expectedPath
|
||||
expect(editor2.getBuffer().getPath()).toBe expectedPath
|
||||
expect(editor2.isFocused).toBeTruthy()
|
||||
|
||||
describe "when no paths are highlighted", ->
|
||||
@@ -159,8 +159,8 @@ describe 'FuzzyFinder', ->
|
||||
finder.trigger 'fuzzy-finder:select-path'
|
||||
|
||||
expect(finder.hasParent()).toBeFalsy()
|
||||
expect(editor1.buffer.getPath()).not.toBe expectedPath
|
||||
expect(editor2.buffer.getPath()).toBe expectedPath
|
||||
expect(editor1.getBuffer().getPath()).not.toBe expectedPath
|
||||
expect(editor2.getBuffer().getPath()).toBe expectedPath
|
||||
expect(editor2.isFocused).toBeTruthy()
|
||||
|
||||
describe "when the highlighted path is not open in the active editor, but instead is open on another editor", ->
|
||||
@@ -179,8 +179,8 @@ describe 'FuzzyFinder', ->
|
||||
finder.trigger 'fuzzy-finder:select-path'
|
||||
|
||||
expect(finder.hasParent()).toBeFalsy()
|
||||
expect(editor1.buffer.getPath()).not.toBe expectedPath
|
||||
expect(editor2.buffer.getPath()).toBe expectedPath
|
||||
expect(editor1.getBuffer().getPath()).not.toBe expectedPath
|
||||
expect(editor2.getBuffer().getPath()).toBe expectedPath
|
||||
expect(editor2.isFocused).toBeTruthy()
|
||||
|
||||
describe "common behavior between file and buffer finder", ->
|
||||
@@ -271,12 +271,12 @@ describe 'FuzzyFinder', ->
|
||||
selectedLi = finder.find('li:eq(1)')
|
||||
|
||||
expectedPath = rootView.project.resolve(selectedLi.text())
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).not.toBe expectedPath
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).not.toBe expectedPath
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
selectedLi.mousedown()
|
||||
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe expectedPath
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).toBe expectedPath
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe ".findMatches(queryString)", ->
|
||||
|
||||
@@ -11,7 +11,7 @@ describe "Snippets extension", ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
rootView.activateExtension(Snippets)
|
||||
editor = rootView.getActiveEditor()
|
||||
buffer = editor.buffer
|
||||
buffer = editor.getBuffer()
|
||||
rootView.simulateDomAttachment()
|
||||
rootView.enableKeymap()
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ describe "StripTrailingWhitespace", ->
|
||||
# works for buffers that are already open when extension is initialized
|
||||
editor.insertText("foo \nbar\t \n\nbaz")
|
||||
editor.save()
|
||||
expect(editor.buffer.getText()).toBe "foo\nbar\n\nbaz"
|
||||
expect(editor.getBuffer().getText()).toBe "foo\nbar\n\nbaz"
|
||||
|
||||
# works for buffers that are opened after extension is initialized
|
||||
rootView.open(require.resolve('fixtures/sample.txt'))
|
||||
editor.moveCursorToEndOfLine()
|
||||
editor.insertText(" ")
|
||||
|
||||
editor.buffer.save()
|
||||
expect(editor.buffer.getText()).toBe 'Some text.\n'
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getBuffer().getText()).toBe 'Some text.\n'
|
||||
|
||||
@@ -171,20 +171,20 @@ describe "TreeView", ->
|
||||
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleJs).toHaveClass 'selected'
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
sampleTxt.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleTxt).toHaveClass 'selected'
|
||||
expect(treeView.find('.selected').length).toBe 1
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.txt')
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.txt')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
describe "when a file is double-clicked", ->
|
||||
it "selects the file and opens it in the active editor on the first click, then changes focus to the active editor on the second", ->
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
|
||||
expect(sampleJs).toHaveClass 'selected'
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeFalsy()
|
||||
|
||||
sampleJs.trigger clickEvent(originalEvent: { detail: 2 })
|
||||
@@ -391,7 +391,7 @@ describe "TreeView", ->
|
||||
it "opens the file in the editor", ->
|
||||
treeView.root.find('.file:contains(sample.js)').click()
|
||||
treeView.root.trigger 'tree-view:open-selected-entry'
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).toBe require.resolve('fixtures/sample.js')
|
||||
|
||||
describe "when a directory is selected", ->
|
||||
it "expands or collapses the directory", ->
|
||||
@@ -470,7 +470,7 @@ describe "TreeView", ->
|
||||
expect(fs.exists(newPath)).toBeTruthy()
|
||||
expect(fs.isFile(newPath)).toBeTruthy()
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).toBe newPath
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).toBe newPath
|
||||
|
||||
waitsFor "tree view to be updated", ->
|
||||
dirView.entries.find("> .file").length > 1
|
||||
@@ -499,7 +499,7 @@ describe "TreeView", ->
|
||||
expect(fs.exists(newPath)).toBeTruthy()
|
||||
expect(fs.isDirectory(newPath)).toBeTruthy()
|
||||
expect(addDialog.parent()).not.toExist()
|
||||
expect(rootView.getActiveEditor().buffer.getPath()).not.toBe newPath
|
||||
expect(rootView.getActiveEditor().getBuffer().getPath()).not.toBe newPath
|
||||
|
||||
describe "when a or directory already exists at the given path", ->
|
||||
it "shows an error message and does not close the dialog", ->
|
||||
|
||||
@@ -27,7 +27,7 @@ xdescribe "VimMode", ->
|
||||
expect(event.stopPropagation).not.toHaveBeenCalled()
|
||||
|
||||
it "does not allow the cursor to be placed on the \n character, unless the line is empty", ->
|
||||
editor.buffer.setText("012345\n\nabcdef")
|
||||
editor.getBuffer().setText("012345\n\nabcdef")
|
||||
editor.setCursorScreenPosition([0, 5])
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0,5]
|
||||
|
||||
@@ -67,121 +67,121 @@ xdescribe "VimMode", ->
|
||||
|
||||
describe "the x keybinding", ->
|
||||
it "deletes a charachter", ->
|
||||
editor.buffer.setText("012345")
|
||||
editor.getBuffer().setText("012345")
|
||||
editor.setCursorScreenPosition([0, 4])
|
||||
|
||||
editor.trigger keydownEvent('x')
|
||||
expect(editor.buffer.getText()).toBe '01235'
|
||||
expect(editor.getBuffer().getText()).toBe '01235'
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0, 4])
|
||||
|
||||
editor.trigger keydownEvent('x')
|
||||
expect(editor.buffer.getText()).toBe '0123'
|
||||
expect(editor.getBuffer().getText()).toBe '0123'
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0, 3])
|
||||
|
||||
editor.trigger keydownEvent('x')
|
||||
expect(editor.buffer.getText()).toBe '012'
|
||||
expect(editor.getBuffer().getText()).toBe '012'
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0, 2])
|
||||
|
||||
it "deletes nothing when cursor is on empty line", ->
|
||||
editor.buffer.setText "012345\n\nabcdef"
|
||||
editor.getBuffer().setText "012345\n\nabcdef"
|
||||
editor.setCursorScreenPosition [1, 0]
|
||||
|
||||
editor.trigger keydownEvent 'x'
|
||||
expect(editor.buffer.getText()).toBe "012345\n\nabcdef"
|
||||
expect(editor.getBuffer().getText()).toBe "012345\n\nabcdef"
|
||||
|
||||
describe "the d keybinding", ->
|
||||
describe "when followed by a d", ->
|
||||
it "deletes the current line", ->
|
||||
editor.buffer.setText("12345\nabcde\nABCDE")
|
||||
editor.getBuffer().setText("12345\nabcde\nABCDE")
|
||||
editor.setCursorScreenPosition([1,1])
|
||||
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('d')
|
||||
expect(editor.buffer.getText()).toBe "12345\nABCDE"
|
||||
expect(editor.getBuffer().getText()).toBe "12345\nABCDE"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1,0])
|
||||
|
||||
it "deletes the last line", ->
|
||||
editor.buffer.setText("12345\nabcde\nABCDE")
|
||||
editor.getBuffer().setText("12345\nabcde\nABCDE")
|
||||
editor.setCursorScreenPosition([2,1])
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('d')
|
||||
expect(editor.buffer.getText()).toBe "12345\nabcde"
|
||||
expect(editor.getBuffer().getText()).toBe "12345\nabcde"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1,0])
|
||||
|
||||
xdescribe "when the second d is prefixed by a count", ->
|
||||
it "deletes n lines, starting from the current", ->
|
||||
editor.buffer.setText("12345\nabcde\nABCDE\nQWERT")
|
||||
editor.getBuffer().setText("12345\nabcde\nABCDE\nQWERT")
|
||||
editor.setCursorScreenPosition([1,1])
|
||||
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('2')
|
||||
editor.trigger keydownEvent('d')
|
||||
|
||||
expect(editor.buffer.getText()).toBe "12345\nQWERT"
|
||||
expect(editor.getBuffer().getText()).toBe "12345\nQWERT"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1,0])
|
||||
|
||||
describe "when followed by an h", ->
|
||||
it "deletes the previous letter on the current line", ->
|
||||
editor.buffer.setText("abcd\n01234")
|
||||
editor.getBuffer().setText("abcd\n01234")
|
||||
editor.setCursorScreenPosition([1,1])
|
||||
|
||||
editor.trigger keydownEvent 'd'
|
||||
editor.trigger keydownEvent 'h'
|
||||
|
||||
expect(editor.buffer.getText()).toBe "abcd\n1234"
|
||||
expect(editor.getBuffer().getText()).toBe "abcd\n1234"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1,0])
|
||||
|
||||
editor.trigger keydownEvent 'd'
|
||||
editor.trigger keydownEvent 'h'
|
||||
|
||||
expect(editor.buffer.getText()).toBe "abcd\n1234"
|
||||
expect(editor.getBuffer().getText()).toBe "abcd\n1234"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([1,0])
|
||||
|
||||
describe "when followed by a w", ->
|
||||
it "deletes to the beginning of the next word", ->
|
||||
editor.buffer.setText("abcd efg")
|
||||
editor.getBuffer().setText("abcd efg")
|
||||
editor.setCursorScreenPosition([0,2])
|
||||
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('w')
|
||||
|
||||
expect(editor.buffer.getText()).toBe "abefg"
|
||||
expect(editor.getBuffer().getText()).toBe "abefg"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0,2])
|
||||
|
||||
editor.buffer.setText("one two three four")
|
||||
editor.getBuffer().setText("one two three four")
|
||||
editor.setCursorScreenPosition([0,0])
|
||||
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('3')
|
||||
editor.trigger keydownEvent('w')
|
||||
|
||||
expect(editor.buffer.getText()).toBe "four"
|
||||
expect(editor.getBuffer().getText()).toBe "four"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0,0])
|
||||
|
||||
describe "when followed by a b", ->
|
||||
it "deletes to the beginning of the previous word", ->
|
||||
editor.buffer.setText("abcd efg")
|
||||
editor.getBuffer().setText("abcd efg")
|
||||
editor.setCursorScreenPosition([0,2])
|
||||
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('b')
|
||||
|
||||
expect(editor.buffer.getText()).toBe "cd efg"
|
||||
expect(editor.getBuffer().getText()).toBe "cd efg"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0,0])
|
||||
|
||||
editor.buffer.setText("one two three four")
|
||||
editor.getBuffer().setText("one two three four")
|
||||
editor.setCursorScreenPosition([0,11])
|
||||
|
||||
editor.trigger keydownEvent('d')
|
||||
editor.trigger keydownEvent('3')
|
||||
editor.trigger keydownEvent('b')
|
||||
|
||||
expect(editor.buffer.getText()).toBe "ee four"
|
||||
expect(editor.getBuffer().getText()).toBe "ee four"
|
||||
expect(editor.getCursorScreenPosition()).toEqual([0,0])
|
||||
|
||||
describe "basic motion bindings", ->
|
||||
beforeEach ->
|
||||
editor.buffer.setText("12345\nabcde\nABCDE")
|
||||
editor.getBuffer().setText("12345\nabcde\nABCDE")
|
||||
editor.setCursorScreenPosition([1,1])
|
||||
|
||||
describe "the h keybinding", ->
|
||||
@@ -215,7 +215,7 @@ xdescribe "VimMode", ->
|
||||
|
||||
describe "the w keybinding", ->
|
||||
it "moves the cursor to the beginning of the next word", ->
|
||||
editor.buffer.setText("ab cde1+- \n xyz\n\nzip")
|
||||
editor.getBuffer().setText("ab cde1+- \n xyz\n\nzip")
|
||||
editor.setCursorScreenPosition([0,0])
|
||||
|
||||
editor.trigger keydownEvent('w')
|
||||
@@ -238,7 +238,7 @@ xdescribe "VimMode", ->
|
||||
|
||||
describe "the { keybinding", ->
|
||||
it "moves the cursor to the beginning of the paragraph", ->
|
||||
editor.buffer.setText("abcde\n\nfghij\nhijk\n xyz \n\nzip\n\n \nthe end")
|
||||
editor.getBuffer().setText("abcde\n\nfghij\nhijk\n xyz \n\nzip\n\n \nthe end")
|
||||
editor.setCursorScreenPosition([0,0])
|
||||
|
||||
editor.trigger keydownEvent('}')
|
||||
@@ -255,7 +255,7 @@ xdescribe "VimMode", ->
|
||||
|
||||
describe "the b keybinding", ->
|
||||
it "moves the cursor to the beginning of the previous word", ->
|
||||
editor.buffer.setText(" ab cde1+- \n xyz\n\nzip }\n last")
|
||||
editor.getBuffer().setText(" ab cde1+- \n xyz\n\nzip }\n last")
|
||||
editor.setCursorScreenPosition [4,1]
|
||||
|
||||
editor.trigger keydownEvent('b')
|
||||
@@ -287,28 +287,28 @@ xdescribe "VimMode", ->
|
||||
|
||||
describe "numeric prefix bindings", ->
|
||||
it "repeats the following operation N times", ->
|
||||
editor.buffer.setText("12345")
|
||||
editor.getBuffer().setText("12345")
|
||||
editor.setCursorScreenPosition([0,1])
|
||||
|
||||
editor.trigger keydownEvent('3')
|
||||
editor.trigger keydownEvent('x')
|
||||
|
||||
expect(editor.buffer.getText()).toBe '15'
|
||||
expect(editor.getBuffer().getText()).toBe '15'
|
||||
|
||||
editor.buffer.setText("123456789abc")
|
||||
editor.getBuffer().setText("123456789abc")
|
||||
editor.setCursorScreenPosition([0,0])
|
||||
editor.trigger keydownEvent('1')
|
||||
editor.trigger keydownEvent('0')
|
||||
editor.trigger keydownEvent('x')
|
||||
|
||||
expect(editor.buffer.getText()).toBe 'bc'
|
||||
expect(editor.getBuffer().getText()).toBe 'bc'
|
||||
|
||||
describe "insert-mode", ->
|
||||
beforeEach ->
|
||||
editor.trigger keydownEvent('i')
|
||||
|
||||
it "allows the cursor to reach the end of the line", ->
|
||||
editor.buffer.setText("012345\n\nabcdef")
|
||||
editor.getBuffer().setText("012345\n\nabcdef")
|
||||
editor.setCursorScreenPosition([0, 5])
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0,5]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user