Fix bug where canceling an autocomplete could delete a previously confirmed completion

This commit is contained in:
Nathan Sobo
2012-06-01 12:00:58 -06:00
parent 9cb067f162
commit 118a48bb47
2 changed files with 14 additions and 0 deletions

View File

@@ -167,6 +167,19 @@ describe "Autocomplete", ->
expect(editor.getSelection().getBufferRange()).toEqual originalSelectionBufferRange
expect(editor.find('.autocomplete')).not.toExist()
fit "does not clear out a previously confirmed selection when canceling with an empty list", ->
editor.buffer.insert([10, 0], "sort\n")
editor.setCursorBufferPosition([10, 0])
autocomplete.attach()
miniEditor.trigger 'autocomplete:confirm'
expect(editor.lineForBufferRow(10)).toBe 'quicksort'
editor.setCursorBufferPosition([11, 0])
autocomplete.attach()
miniEditor.trigger 'autocomplete:cancel'
expect(editor.lineForBufferRow(10)).toBe 'quicksort'
describe 'move-up event', ->
it "highlights the previous match and replaces the selection with it", ->
editor.buffer.insert([10,0] ,"extra:t:extra")

View File

@@ -104,6 +104,7 @@ class Autocomplete extends View
@originalSelectedText = @editor.getSelectedText()
@originalSelectionBufferRange = @editor.getSelection().getBufferRange()
@currentMatchBufferRange = null
@allMatches = @findMatchesForCurrentSelection()