mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
less code for tab overwriting
This commit is contained in:
+7
-17
@@ -436,19 +436,6 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
protected static void selectLookupItem(final LookupElement item, final char completionChar, final CompletionProgressIndicator context, final List<LookupElement> items) {
|
||||
final int caretOffset = context.getEditor().getCaretModel().getOffset();
|
||||
|
||||
context.getOffsetMap().addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, caretOffset);
|
||||
final int idEnd = context.getIdentifierEndOffset();
|
||||
final int identifierEndOffset =
|
||||
CompletionUtil.isOverwrite(item, completionChar) && context.getSelectionEndOffset() == idEnd ?
|
||||
caretOffset :
|
||||
Math.max(caretOffset, idEnd);
|
||||
context.getOffsetMap().addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, identifierEndOffset);
|
||||
lookupItemSelected(context, item, completionChar, items);
|
||||
}
|
||||
|
||||
private CompletionContext insertDummyIdentifier(CompletionInitializationContext initContext) {
|
||||
final PsiFile originalFile = initContext.getFile();
|
||||
PsiFile fileCopy = createFileCopy(originalFile);
|
||||
@@ -500,17 +487,21 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
return invokedExplicitly && CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX;
|
||||
}
|
||||
|
||||
private static void lookupItemSelected(final CompletionProgressIndicator indicator, @NotNull final LookupElement item, final char completionChar,
|
||||
protected static void lookupItemSelected(final CompletionProgressIndicator indicator, @NotNull final LookupElement item, final char completionChar,
|
||||
final List<LookupElement> items) {
|
||||
if (indicator.getHandler().autopopup) {
|
||||
if (indicator.isAutopopupCompletion()) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_BASIC);
|
||||
}
|
||||
|
||||
final Editor editor = indicator.getEditor();
|
||||
final int caretOffset = editor.getCaretModel().getOffset();
|
||||
indicator.getOffsetMap().addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, caretOffset);
|
||||
|
||||
final WatchingInsertionContext context = new WatchingInsertionContext(indicator, completionChar, items, editor);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
final int idEndOffset = indicator.getIdentifierEndOffset();
|
||||
final int idEndOffset = Math.max(caretOffset, indicator.getIdentifierEndOffset());
|
||||
indicator.getOffsetMap().addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, idEndOffset);
|
||||
if (idEndOffset != indicator.getSelectionEndOffset() && CompletionUtil.isOverwrite(item, completionChar)) {
|
||||
editor.getDocument().deleteString(indicator.getSelectionEndOffset(), idEndOffset);
|
||||
}
|
||||
@@ -522,7 +513,6 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler {
|
||||
item.handleInsert(context);
|
||||
PostprocessReformattingAspect.getInstance(indicator.getProject()).doPostponedFormatting();
|
||||
|
||||
|
||||
final int tailOffset = context.getTailOffset();
|
||||
if (tailOffset >= 0) {
|
||||
if (context.shouldAddCompletionChar()) {
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
|
||||
|
||||
myOffsetMap.addOffset(CompletionInitializationContext.START_OFFSET,
|
||||
myEditor.getCaretModel().getOffset() - item.getLookupString().length());
|
||||
CodeCompletionHandlerBase.selectLookupItem(item, event.getCompletionChar(), CompletionProgressIndicator.this, myLookup.getItems());
|
||||
CodeCompletionHandlerBase.lookupItemSelected(CompletionProgressIndicator.this, item, event.getCompletionChar(), myLookup.getItems());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user