A Regex file extension that makes it way easier to edit large regex.
removes highlights on reset
2 files changed, +18 -1
+2-0src/decorationSelector.ts
| @@ -51,6 +51,8 @@ class DecorationSelector { | ||
| 51 | 51 | |
| 52 | 52 | reset() { |
| 53 | 53 | this.currentIndex = 0; |
| 54 | + for (const decoration of this.decorations) { | |
| 55 | + } | |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | select() { |
+16-1src/highlighter.ts
| @@ -1,6 +1,11 @@ | ||
| 1 | 1 | import * as vscode from "vscode"; |
| 2 | 2 | import { output } from "./output"; |
| 3 | -import { getNonRegexEditors, getRegexEditor, timeit } from "./utils"; | |
| 3 | +import { | |
| 4 | + editorsContainRegexFile, | |
| 5 | + getNonRegexEditors, | |
| 6 | + getRegexEditor, | |
| 7 | + timeit, | |
| 8 | +} from "./utils"; | |
| 4 | 9 | import { regexButtons } from "./regexButtons"; |
| 5 | 10 | import decorationSelector from "./decorationSelector"; |
| 6 | 11 | import { getConfig } from "./global"; |
| @@ -31,6 +36,7 @@ class Highlighter { | ||
| 31 | 36 | @timeit |
| 32 | 37 | reset() { |
| 33 | 38 | output.clear(); |
| 39 | + this.removeHighlights(); | |
| 34 | 40 | this.highlightGroups = {}; |
| 35 | 41 | decorationSelector.reset(); |
| 36 | 42 | } |
| @@ -143,6 +149,15 @@ class Highlighter { | ||
| 143 | 149 | } |
| 144 | 150 | } |
| 145 | 151 | |
| 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 | + | |
| 146 | 161 | run() { |
| 147 | 162 | this.reset(); |
| 148 | 163 | const regexEditor = getRegexEditor(); |