A Regex file extension that makes it way easier to edit large regex.
searches the correct files
4 files changed, +14 -12
+2-2src/extension.ts
| @@ -12,7 +12,7 @@ export function activate(context: vscode.ExtensionContext) { | ||
| 12 | 12 | vscode.window.onDidChangeActiveTextEditor((editor) => { |
| 13 | 13 | if (editor && editor.document.uri.scheme === "file") { |
| 14 | 14 | if (editor.document.languageId === "regex") { |
| 15 | - output.log("Regex file opened"); | |
| 15 | + // output.log("Regex file opened"); | |
| 16 | 16 | highlighter.run(); |
| 17 | 17 | } |
| 18 | 18 | } |
| @@ -29,6 +29,6 @@ export function activate(context: vscode.ExtensionContext) { | ||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | export function deactivate() { |
| 32 | - output.log("Stopping File Regex extension"); | |
| 32 | + // output.log("Stopping File Regex extension"); | |
| 33 | 33 | output.deactivate(); |
| 34 | 34 | } |
+6-4src/highlighter.ts
| @@ -17,17 +17,18 @@ class Highlighter { | ||
| 17 | 17 | constructor() {} |
| 18 | 18 | |
| 19 | 19 | activate(context: vscode.ExtensionContext) { |
| 20 | - output.log("Highlighter activated"); | |
| 20 | + // output.log("Highlighter activated"); | |
| 21 | 21 | this.context = context; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | reset() { |
| 25 | - output.log("Resetting decorations"); | |
| 25 | + // output.log("Resetting decorations"); | |
| 26 | 26 | this.decorations.forEach((decoration) => { |
| 27 | 27 | decoration.dispose(); |
| 28 | 28 | }); |
| 29 | 29 | this.decorations = []; |
| 30 | 30 | decorationGenerator.reset(); |
| 31 | + output.clear(); | |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | getHighlightGroups( |
| @@ -46,7 +47,7 @@ class Highlighter { | ||
| 46 | 47 | const maxMatches = getConfig().get("maxMatches") as number; |
| 47 | 48 | for (const match of matches) { |
| 48 | 49 | if (i >= maxMatches) { |
| 49 | - break; | |
| 50 | + continue; | |
| 50 | 51 | } |
| 51 | 52 | const start = document.positionAt(match.index); |
| 52 | 53 | const end = document.positionAt(match.index + match[0].length); |
| @@ -56,11 +57,12 @@ class Highlighter { | ||
| 56 | 57 | }); |
| 57 | 58 | i++; |
| 58 | 59 | } |
| 60 | + output.log(`Found ${i} matches`); | |
| 59 | 61 | return highlightGroups; |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | 64 | highlightMatches(regexEditor: vscode.TextEditor, editor: vscode.TextEditor) { |
| 63 | - output.log(`Highlighting matches in ${editor.document.fileName}`); | |
| 65 | + // output.log(`Highlighting matches in ${editor.document.fileName}`); | |
| 64 | 66 | const regex = regexEditor.document.getText(); |
| 65 | 67 | const flags = regexButtons.getFlagString(); |
| 66 | 68 | const highlightGroups = this.getHighlightGroups( |
+4-4src/regexButtons.ts
| @@ -79,7 +79,7 @@ class RegexButtons { | ||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | toggleFlag(flag: Flag) { |
| 82 | - output.log(`Toggling flag ${flag.char}`); | |
| 82 | + // output.log(`Toggling flag ${flag.char}`); | |
| 83 | 83 | flag.state = flag.state === "on" ? "off" : "on"; |
| 84 | 84 | this.decorateFlag(flag); |
| 85 | 85 | } |
| @@ -93,7 +93,7 @@ class RegexButtons { | ||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | createButton(flag: Flag) { |
| 96 | - output.log(`Creating button for ${flag}`); | |
| 96 | + // output.log(`Creating button for ${flag}`); | |
| 97 | 97 | flag.button = vscode.window.createStatusBarItem( |
| 98 | 98 | vscode.StatusBarAlignment.Left |
| 99 | 99 | ); |
| @@ -111,14 +111,14 @@ class RegexButtons { | ||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | createButtons() { |
| 114 | - output.log("Creating buttons"); | |
| 114 | + // output.log("Creating buttons"); | |
| 115 | 115 | for (const flag of FLAG_CHARS) { |
| 116 | 116 | this.createButton(flag); |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | disposeButtons() { |
| 121 | - output.log("Disposing buttons"); | |
| 121 | + // output.log("Disposing buttons"); | |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | dispose() { |
+2-2src/utils.ts
| @@ -22,7 +22,7 @@ export function getNonRegexEditors() { | ||
| 22 | 22 | const editors = vscode.window.visibleTextEditors; |
| 23 | 23 | return editors.filter( |
| 24 | 24 | (editor) => |
| 25 | - editor.document.languageId !== "regex" || | |
| 26 | - editor.document.uri.scheme !== "file" | |
| 25 | + editor.document.languageId !== "regex" && | |
| 26 | + editor.document.uri.scheme === "file" | |
| 27 | 27 | ); |
| 28 | 28 | } |