From 76cda5f8725f08fb44a31bc752bfad328f4a4add Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 3 Jan 2013 16:59:55 -0800 Subject: [PATCH] Delete suffix before prefix This allows the cursor buffer position to only be obtained once from the editor. --- src/packages/autocomplete/src/autocomplete.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/packages/autocomplete/src/autocomplete.coffee b/src/packages/autocomplete/src/autocomplete.coffee index 94b7ac09b..885380e65 100644 --- a/src/packages/autocomplete/src/autocomplete.coffee +++ b/src/packages/autocomplete/src/autocomplete.coffee @@ -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++