irongit

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

no more console outputs

huncholanehuncholaneauthored
parent 298ba72commit d26ade4fe5390c3f3c7f9e46966a4b9a636e78d0Browse files

3 files changed, +29 -16

+28-14src/extension.ts
@@ -9,27 +9,41 @@ export function activate(context: vscode.ExtensionContext) {
99 regexButtons.activate(context);
1010 highlighter.activate(context);
1111
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+ }
2027 }
2128 }
22- });
29+ );
2330
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+ }
2736 }
28- });
37+ );
38+
39+ context.subscriptions.push(activeEditorListener, textDocumentListener);
2940 }
3041
3142 export function deactivate() {
32- output.dispose();
3343 highlighter.dispose();
44+ // console.log("Disposed highlighter");
3445 regexButtons.dispose();
46+ // console.log("Disposed regexButtons");
47+ output.dispose();
48+ // console.log("Disposed Output");
3549 }
+1-1src/output.ts
@@ -58,7 +58,7 @@ class Output {
5858 coloredOutput += `${yellow}[warning] ${reset}`;
5959 }
6060 coloredOutput += `${whiteBright}${message}${reset}`;
61- console.log(coloredOutput);
61+ // console.log(coloredOutput);
6262
6363 // Log to VS Code output channel without colors
6464 this.outputChannel?.appendLine(message);
+0-1src/utils.ts
@@ -42,7 +42,6 @@ export function timeit(
4242 const originalMethod = descriptor.value;
4343 descriptor.value = function (...args: any[]) {
4444 const start = new Date().getTime();
45- output.log("Starting " + propertyKey);
4645 const result = originalMethod.apply(this, args);
4746 output.log(`Executed ${propertyKey} in ${new Date().getTime() - start}ms`);
4847 return result;