import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.command.impl.FinishMarkAction;
import com.intellij.openapi.command.impl.StartMarkAction;
-import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.ScrollType;
-import com.intellij.openapi.editor.VisualPosition;
+import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.event.DocumentEvent;
@Override
public void documentChanged(DocumentEvent event) {
+ RangeMarker marker = event.getDocument().createRangeMarker(event.getOffset(), event.getOffset());
myDocumentManager.performWhenAllCommitted(() -> {
if (myDetector == null) {
return;
if (file == null) {
return;
}
- PsiElement element = file.findElementAt(event.getOffset());
- if (myDetector.ignoreChanges(element)) return;
+ PsiElement element = file.findElementAt(marker.getStartOffset());
+ marker.dispose();
+ if (element == null || myDetector.ignoreChanges(element)) return;
if (element instanceof PsiWhiteSpace) {
PsiElement method = myStableChange.getMethod();
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(checkBox, null).setSmallVariant(true);
myBalloon = balloonBuilder.createBalloon();
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
- final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
@Override
public RelativePoint recalculateLocation(Balloon object) {
}
myHighlighters.clear();
myBalloon.hide();
+ myDetector = null;
FinishMarkAction.finish(myProject, myEditor, myMarkAction);
myEditor.putUserData(INPLACE_CHANGE_SIGNATURE, null);
}