A Regex file extension that makes it way easier to edit large regex.
no more console outputs
3 files changed, +29 -16
+28-14src/extension.ts
| @@ -9,27 +9,41 @@ export function activate(context: vscode.ExtensionContext) { | ||
| 9 | 9 | regexButtons.activate(context); |
| 10 | 10 | highlighter.activate(context); |
| 11 | 11 | |
| 12 | - vscode.window.onDidChangeActiveTextEditor((editor) => { | |
| 13 | - if (editor && editor.document.uri.scheme === "file") { | |
| 14 | - if (editorsContainRegexFile()) { | |
| 15 | - highlighter.run(); | |
| 16 | - regexButtons.show(); | |
| 17 | - } else { | |
| 18 | - highlighter.reset(); | |
| 19 | - regexButtons.hide(); | |
| 12 | + if (editorsContainRegexFile()) { | |
| 13 | + highlighter.run(); | |
| 14 | + regexButtons.show(); | |
| 15 | + } | |
| 16 | + | |
| 17 | + const activeEditorListener = vscode.window.onDidChangeActiveTextEditor( | |
| 18 | + (editor) => { | |
| 19 | + if (editor && editor.document.uri.scheme === "file") { | |
| 20 | + if (editorsContainRegexFile()) { | |
| 21 | + highlighter.run(); | |
| 22 | + regexButtons.show(); | |
| 23 | + } else { | |
| 24 | + highlighter.reset(); | |
| 25 | + regexButtons.hide(); | |
| 26 | + } | |
| 20 | 27 | } |
| 21 | 28 | } |
| 22 | - }); | |
| 29 | + ); | |
| 23 | 30 | |
| 24 | - vscode.workspace.onDidChangeTextDocument((event) => { | |
| 25 | - if (editorsContainRegexFile() && event.document.uri.scheme === "file") { | |
| 26 | - highlighter.run(); | |
| 31 | + const textDocumentListener = vscode.workspace.onDidChangeTextDocument( | |
| 32 | + (event) => { | |
| 33 | + if (editorsContainRegexFile() && event.document.uri.scheme === "file") { | |
| 34 | + highlighter.run(); | |
| 35 | + } | |
| 27 | 36 | } |
| 28 | - }); | |
| 37 | + ); | |
| 38 | + | |
| 39 | + context.subscriptions.push(activeEditorListener, textDocumentListener); | |
| 29 | 40 | } |
| 30 | 41 | |
| 31 | 42 | export function deactivate() { |
| 32 | - output.dispose(); | |
| 33 | 43 | highlighter.dispose(); |
| 44 | + // console.log("Disposed highlighter"); | |
| 34 | 45 | regexButtons.dispose(); |
| 46 | + // console.log("Disposed regexButtons"); | |
| 47 | + output.dispose(); | |
| 48 | + // console.log("Disposed Output"); | |
| 35 | 49 | } |
+1-1src/output.ts
| @@ -58,7 +58,7 @@ class Output { | ||
| 58 | 58 | coloredOutput += `${yellow}[warning] ${reset}`; |
| 59 | 59 | } |
| 60 | 60 | coloredOutput += `${whiteBright}${message}${reset}`; |
| 61 | - console.log(coloredOutput); | |
| 61 | + // console.log(coloredOutput); | |
| 62 | 62 | |
| 63 | 63 | // Log to VS Code output channel without colors |
| 64 | 64 | this.outputChannel?.appendLine(message); |
+0-1src/utils.ts
| @@ -42,7 +42,6 @@ export function timeit( | ||
| 42 | 42 | const originalMethod = descriptor.value; |
| 43 | 43 | descriptor.value = function (...args: any[]) { |
| 44 | 44 | const start = new Date().getTime(); |
| 45 | - output.log("Starting " + propertyKey); | |
| 46 | 45 | const result = originalMethod.apply(this, args); |
| 47 | 46 | output.log(`Executed ${propertyKey} in ${new Date().getTime() - start}ms`); |
| 48 | 47 | return result; |