mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Canceling autocomplete restores text and selection, even if selection has changed before cancel
This commit is contained in:
@@ -90,7 +90,7 @@ class Autocomplete extends View
|
||||
|
||||
cancel: ->
|
||||
@detach()
|
||||
@editor.getSelection().insertText @originalSelectedText
|
||||
@editor.buffer.change(@currentMatchBufferRange, @originalSelectedText) if @currentMatchBufferRange
|
||||
@editor.setSelectionBufferRange(@originalSelectionBufferRange)
|
||||
|
||||
attach: ->
|
||||
@@ -173,7 +173,9 @@ class Autocomplete extends View
|
||||
startPosition = selection.getBufferRange().start
|
||||
@isAutocompleting = true
|
||||
@editor.insertText(match.infix)
|
||||
@editor.setSelectionBufferRange([startPosition, [startPosition.row, startPosition.column + match.infix.length]])
|
||||
|
||||
@currentMatchBufferRange = [startPosition, [startPosition.row, startPosition.column + match.infix.length]]
|
||||
@editor.setSelectionBufferRange(@currentMatchBufferRange)
|
||||
@isAutocompleting = false
|
||||
|
||||
prefixAndSuffixOfSelection: (selection) ->
|
||||
|
||||
Reference in New Issue
Block a user