mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
IDEA-130774 Cyclic expand word overwrites following characters
This commit is contained in:
+8
@@ -211,6 +211,14 @@ foo->bar
|
||||
'''
|
||||
}
|
||||
|
||||
public void "test inside word"() {
|
||||
myFixture.configureByText "a.c", 'foo fox f<caret>bar'
|
||||
complete()
|
||||
myFixture.checkResult 'foo fox fox<caret>bar'
|
||||
complete()
|
||||
myFixture.checkResult 'foo fox foo<caret>bar'
|
||||
}
|
||||
|
||||
private void complete() {
|
||||
myFixture.performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION)
|
||||
}
|
||||
|
||||
+3
-4
@@ -55,8 +55,8 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
public void invoke(@NotNull Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
if (editor.isViewer() || editor.getDocument().getRangeGuard(offset, offset) != null) {
|
||||
int caretOffset = editor.getCaretModel().getOffset();
|
||||
if (editor.isViewer() || editor.getDocument().getRangeGuard(caretOffset, caretOffset) != null) {
|
||||
editor.getDocument().fireReadOnlyModificationAttempt();
|
||||
CodeInsightUtilBase.showReadOnlyViewWarning(editor);
|
||||
return;
|
||||
@@ -87,8 +87,7 @@ public class HippieWordCompletionHandler implements CodeInsightActionHandler {
|
||||
CompletionVariant nextVariant = computeNextVariant(editor, oldPrefix, lastProposedVariant, data, file, fromOtherFiles, false);
|
||||
if (nextVariant == null) return;
|
||||
|
||||
int replacementEnd = data.startOffset + data.myWordUnderCursor.length();
|
||||
editor.getDocument().replaceString(data.startOffset, replacementEnd, nextVariant.variant);
|
||||
editor.getDocument().replaceString(data.startOffset, caretOffset, nextVariant.variant);
|
||||
editor.getCaretModel().moveToOffset(data.startOffset + nextVariant.variant.length());
|
||||
completionState.lastProposedVariant = nextVariant;
|
||||
completionState.fromOtherFiles = nextVariant.editor != editor;
|
||||
|
||||
Reference in New Issue
Block a user