irongit

A Regex file extension that makes it way easier to edit large regex.

removes highlights on reset

huncholanehuncholaneauthored
parent 0104ec9commit 36cf38ded3a2d16d542fbe1df665f5bba75246c9Browse files

2 files changed, +18 -1

+2-0src/decorationSelector.ts
@@ -51,6 +51,8 @@ class DecorationSelector {
5151
5252 reset() {
5353 this.currentIndex = 0;
54+ for (const decoration of this.decorations) {
55+ }
5456 }
5557
5658 select() {
+16-1src/highlighter.ts
@@ -1,6 +1,11 @@
11 import * as vscode from "vscode";
22 import { output } from "./output";
3-import { getNonRegexEditors, getRegexEditor, timeit } from "./utils";
3+import {
4+ editorsContainRegexFile,
5+ getNonRegexEditors,
6+ getRegexEditor,
7+ timeit,
8+} from "./utils";
49 import { regexButtons } from "./regexButtons";
510 import decorationSelector from "./decorationSelector";
611 import { getConfig } from "./global";
@@ -31,6 +36,7 @@ class Highlighter {
3136 @timeit
3237 reset() {
3338 output.clear();
39+ this.removeHighlights();
3440 this.highlightGroups = {};
3541 decorationSelector.reset();
3642 }
@@ -143,6 +149,15 @@ class Highlighter {
143149 }
144150 }
145151
152+ removeHighlights() {
153+ for (const editor of vscode.window.visibleTextEditors) {
154+ for (const key of Object.keys(this.highlightGroups)) {
155+ const group = this.highlightGroups[key];
156+ editor.setDecorations(group.decorationType, []);
157+ }
158+ }
159+ }
160+
146161 run() {
147162 this.reset();
148163 const regexEditor = getRegexEditor();