mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
correct disabling of tag tree highlighting
This commit is contained in:
+25
@@ -15,8 +15,16 @@
|
||||
*/
|
||||
package com.intellij.application.options.editor;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.HtmlTagTreeHighlightingPass;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.options.BeanConfigurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.xml.XmlBundle;
|
||||
|
||||
/**
|
||||
@@ -30,4 +38,21 @@ public class WebEditorAppearanceConfigurable extends BeanConfigurable<WebEditorO
|
||||
checkBox("showCssColorPreviewInGutter", "Show CSS Color preview icon in gutter");
|
||||
checkBox("tagTreeHighlightingEnabled", "Enable HTML tag tree highlighting");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
super.apply();
|
||||
clearTagTreeHighlighting();
|
||||
}
|
||||
|
||||
private static void clearTagTreeHighlighting() {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
|
||||
if (fileEditor instanceof TextEditor) {
|
||||
final Editor editor = ((TextEditor)fileEditor).getEditor();
|
||||
HtmlTagTreeHighlightingPass.clearHighlightingAndLineMarkers(editor, project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-5
@@ -33,6 +33,7 @@ import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -153,7 +154,7 @@ public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
|
||||
public List<HighlightInfo> getHighlights() {
|
||||
removeOldLineMarkers();
|
||||
clearLineMarkers(myEditor);
|
||||
|
||||
final int count = myPairsToHighlight.size();
|
||||
final List<HighlightInfo> highlightInfos = new ArrayList<HighlightInfo>(count * 2);
|
||||
@@ -196,18 +197,18 @@ public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
return highlightInfos;
|
||||
}
|
||||
|
||||
private void removeOldLineMarkers() {
|
||||
final List<RangeHighlighter> oldHighlighters = myEditor.getUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY);
|
||||
private static void clearLineMarkers(Editor editor) {
|
||||
final List<RangeHighlighter> oldHighlighters = editor.getUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY);
|
||||
|
||||
if (oldHighlighters != null) {
|
||||
final MarkupModelEx markupModel = (MarkupModelEx)myEditor.getMarkupModel();
|
||||
final MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel();
|
||||
|
||||
for (RangeHighlighter highlighter : oldHighlighters) {
|
||||
if (markupModel.containsHighlighter(highlighter)) {
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
myEditor.putUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY, null);
|
||||
editor.putUserData(TAG_TREE_HIGHLIGHTERS_IN_EDITOR_KEY, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,4 +294,22 @@ public class HtmlTagTreeHighlightingPass extends TextEditorHighlightingPass {
|
||||
|
||||
return colors;
|
||||
}
|
||||
|
||||
public static void clearHighlightingAndLineMarkers(final Editor editor, @NotNull Project project) {
|
||||
final MarkupModel markupModel = editor.getDocument().getMarkupModel(project);
|
||||
|
||||
for (RangeHighlighter highlighter : markupModel.getAllHighlighters()) {
|
||||
Object tooltip = highlighter.getErrorStripeTooltip();
|
||||
|
||||
if (!(tooltip instanceof HighlightInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((HighlightInfo)tooltip).type == TYPE) {
|
||||
highlighter.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
clearLineMarkers(editor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user