mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
1-to-1 mapping between Caret instances for injected and main editors (IDEA-80056)
allows to compare Caret instances using == in generic code
This commit is contained in:
+1
-1
@@ -628,7 +628,7 @@ public class CodeCompletionHandlerBase {
|
||||
@Override
|
||||
public void perform(Caret caret) {
|
||||
CompletionAssertions.WatchingInsertionContext currentContext = insertItem(indicator, item, completionChar, items, update, editor, caret.getOffset(), caret.getOffset() + idEndOffsetDelta);
|
||||
if (caret.getVisualPosition().equals(editor.getCaretModel().getPrimaryCaret().getVisualPosition())) {
|
||||
if (caret == editor.getCaretModel().getPrimaryCaret()) {
|
||||
contextRef.set(currentContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Alexey
|
||||
@@ -37,6 +35,7 @@ public class CaretModelWindow implements CaretModel {
|
||||
private final CaretModel myDelegate;
|
||||
private final EditorEx myHostEditor;
|
||||
private final EditorWindow myEditorWindow;
|
||||
private final Map<Caret, InjectedCaret> myInjectedCaretMap = new WeakHashMap<Caret, InjectedCaret>();
|
||||
|
||||
public CaretModelWindow(CaretModel delegate, EditorWindow editorWindow) {
|
||||
myDelegate = delegate;
|
||||
@@ -219,7 +218,17 @@ public class CaretModelWindow implements CaretModel {
|
||||
}
|
||||
|
||||
private InjectedCaret createInjectedCaret(Caret caret) {
|
||||
return caret == null ? null : new InjectedCaret(myEditorWindow, caret);
|
||||
if (caret == null) {
|
||||
return null;
|
||||
}
|
||||
synchronized (myInjectedCaretMap) {
|
||||
InjectedCaret injectedCaret = myInjectedCaretMap.get(caret);
|
||||
if (injectedCaret == null) {
|
||||
injectedCaret = new InjectedCaret(myEditorWindow, caret);
|
||||
myInjectedCaretMap.put(caret, injectedCaret);
|
||||
}
|
||||
return injectedCaret;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user