mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Cancel select list when an empty selection is confirmed
This commit is contained in:
@@ -121,6 +121,14 @@ describe "SelectList", ->
|
||||
miniEditor.trigger 'core:confirm'
|
||||
expect(selectList.confirmed).not.toHaveBeenCalled()
|
||||
|
||||
it "does trigger the cancelled hook", ->
|
||||
miniEditor.insertText("i will never match anything")
|
||||
window.advanceClock(selectList.inputThrottle)
|
||||
|
||||
expect(list.find('li')).not.toExist()
|
||||
miniEditor.trigger 'core:confirm'
|
||||
expect(selectList.cancelled).toHaveBeenCalled()
|
||||
|
||||
describe "when a list item is clicked", ->
|
||||
it "selects the item on mousedown and confirms it on mouseup", ->
|
||||
item = list.find('li:eq(1)')
|
||||
|
||||
@@ -117,7 +117,10 @@ class SelectList extends View
|
||||
|
||||
confirmSelection: ->
|
||||
element = @getSelectedElement()
|
||||
@confirmed(element) if element?
|
||||
if element?
|
||||
@confirmed(element)
|
||||
else
|
||||
@cancel()
|
||||
|
||||
cancel: ->
|
||||
@list.empty()
|
||||
|
||||
@@ -165,7 +165,6 @@ describe "Autocomplete", ->
|
||||
editor.getBuffer().insert([10,0] ,"extra:sh:extra")
|
||||
editor.setCursorBufferPosition([10,8])
|
||||
autocomplete.attach()
|
||||
miniEditor.trigger "core:confirm"
|
||||
|
||||
expect(editor.lineForBufferRow(10)).toBe "extra:shift:extra"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10,11]
|
||||
@@ -201,7 +200,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.getBuffer().insert([10, 0], "sort\n")
|
||||
editor.getBuffer().insert([10, 0], "ort\n")
|
||||
editor.setCursorBufferPosition([10, 0])
|
||||
|
||||
autocomplete.attach()
|
||||
|
||||
@@ -89,7 +89,7 @@ class Autocomplete extends SelectList
|
||||
@setArray(matches)
|
||||
|
||||
if matches.length is 1
|
||||
@confirmed matches[0]
|
||||
@confirmSelection()
|
||||
else
|
||||
@editor.appendToLinesView(this)
|
||||
@setPosition(originalCursorPosition)
|
||||
|
||||
Reference in New Issue
Block a user