Delete suffix before prefix

This allows the cursor buffer position to only be
obtained once from the editor.
This commit is contained in:
Kevin Sawicki
2013-01-03 16:59:55 -08:00
parent 7b7dccbd79
commit 76cda5f872

View File

@@ -135,8 +135,9 @@ class Autocomplete extends SelectList
buffer = @editor.getBuffer()
@editor.activeEditSession.transact =>
selection.deleteSelectedText()
buffer.delete(Range.fromPointWithDelta(@editor.getCursorBufferPosition(), 0, -match.prefix.length))
buffer.delete(Range.fromPointWithDelta(@editor.getCursorBufferPosition(), 0, match.suffix.length))
cursorPosition = @editor.getCursorBufferPosition()
buffer.delete(Range.fromPointWithDelta(cursorPosition, 0, match.suffix.length))
buffer.delete(Range.fromPointWithDelta(cursorPosition, 0, -match.prefix.length))
@editor.insertText(match.word)
@undoCount++