From 4e80a49ed53671d088c6c955e76469dde082f688 Mon Sep 17 00:00:00 2001 From: Tatiana Fesenko Date: Tue, 3 Oct 2017 12:21:27 -0400 Subject: [PATCH] #227 - restore cursor position for empty selection - it should be at the _end_ of the inserted proposal --- .../swagedit/core/assist/StyledCompletionProposal.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/assist/StyledCompletionProposal.java b/com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/assist/StyledCompletionProposal.java index 642569ee..a3c54333 100644 --- a/com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/assist/StyledCompletionProposal.java +++ b/com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/assist/StyledCompletionProposal.java @@ -84,8 +84,8 @@ public Point getSelection(IDocument document) { offset = replacementOffset - prefix.length(); } } - int replacementIndex = replacementString.indexOf(selection); - int selectionStart = offset + (replacementIndex < 0 ? 0 : replacementIndex); + int replacementIndex = !"".equals(selection) ? replacementString.indexOf(selection) : -1; + int selectionStart = offset + (replacementIndex < 0 ? replacementString.length() : replacementIndex); return new Point(selectionStart, selection.length()); }