mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Autocomplete is cancelled if the mini editor loses focus before a selection is confirmed
This commit is contained in:
@@ -307,10 +307,10 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.parent()).not.toExist()
|
||||
expect(editor.lineForBufferRow(10)).toEqual 'pivot '
|
||||
|
||||
describe 'when the editor is focused', ->
|
||||
describe 'when the mini-editor loses focus before the selection is confirmed', ->
|
||||
it "cancels the autocomplete", ->
|
||||
editor.attachToDom()
|
||||
autocomplete.attach()
|
||||
|
||||
spyOn(autocomplete, "cancel")
|
||||
|
||||
editor.focus()
|
||||
|
||||
@@ -82,6 +82,7 @@ class Autocomplete extends View
|
||||
@wordList = _.unique(@currentBuffer.getText().match(@wordRegex))
|
||||
|
||||
confirm: ->
|
||||
@confirmed = true
|
||||
@editor.getSelection().clearSelection()
|
||||
@detach()
|
||||
return unless match = @selectedMatch()
|
||||
@@ -94,7 +95,8 @@ class Autocomplete extends View
|
||||
@editor.setSelectionBufferRange(@originalSelectionBufferRange)
|
||||
|
||||
attach: ->
|
||||
@editor.on 'focus.autocomplete', => @cancel()
|
||||
@confirmed = false
|
||||
@miniEditor.on 'focusout', => @cancel() unless @confirmed
|
||||
|
||||
@originalSelectedText = @editor.getSelectedText()
|
||||
@originalSelectionBufferRange = @editor.getSelection().getBufferRange()
|
||||
|
||||
Reference in New Issue
Block a user