mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[spellchecker] fix RIDER-106853
GitOrigin-RevId: 16f5a49227de384193be807d3b9459e4b2babc11
This commit is contained in:
committed by
intellij-monorepo-bot
parent
193b2cb477
commit
ce9da5e101
@@ -476,4 +476,25 @@ public final class UpdateHighlightersUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all highlighters with exactly the given range from {@link DocumentMarkupModel} produced by given inspection.
|
||||
* This might be useful in quick fixes and intention actions to provide immediate feedback.
|
||||
* This method currently works in O(total highlighter count in file) time.
|
||||
*/
|
||||
public static void removeHighlightersWithExactRange(@NotNull Document document, @NotNull Project project, @NotNull Segment range, @NotNull String inspectionToolId) {
|
||||
if (IntentionPreviewUtils.isIntentionPreviewActive()) return;
|
||||
ThreadingAssertions.assertEventDispatchThread();
|
||||
MarkupModel model = DocumentMarkupModel.forDocument(document, project, false);
|
||||
if (model == null) return;
|
||||
|
||||
for (RangeHighlighter highlighter : model.getAllHighlighters()) {
|
||||
if (TextRange.areSegmentsEqual(range, highlighter)) {
|
||||
var highlightInfo = HighlightInfo.fromRangeHighlighter(highlighter);
|
||||
if (highlightInfo != null && !inspectionToolId.equals(highlightInfo.getInspectionToolId())) {
|
||||
continue;
|
||||
}
|
||||
model.removeHighlighter(highlighter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.spellchecker.DictionaryLayer;
|
||||
import com.intellij.spellchecker.DictionaryLayersProvider;
|
||||
import com.intellij.spellchecker.SpellCheckerManager;
|
||||
import com.intellij.spellchecker.inspections.SpellCheckingInspection;
|
||||
import com.intellij.spellchecker.util.SpellCheckerBundle;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -101,7 +102,7 @@ public final class SaveTo implements SpellCheckerQuickFix, LowPriorityAction {
|
||||
SpellCheckerManager.getInstance(project).acceptWordAsCorrect$intellij_spellchecker(word, file.getViewProvider().getVirtualFile(), project, layer);
|
||||
|
||||
TextRange range = descriptor.getTextRangeInElement().shiftRight(psi.getTextRange().getStartOffset());
|
||||
UpdateHighlightersUtil.removeHighlightersWithExactRange(file.getViewProvider().getDocument(), project, range);
|
||||
UpdateHighlightersUtil.removeHighlightersWithExactRange(file.getViewProvider().getDocument(), project, range, SpellCheckingInspection.SPELL_CHECKING_INSPECTION_TOOL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user