From d1872cfc74f9d46687d729cdd479e4ee32bbd9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Fri, 8 May 2026 12:42:02 +0300 Subject: [PATCH 1/8] src/editorDecorator.ts: moves utils to their only user's file. --- src/editorDecorator.ts | 19 +++++++++++++------ src/utilities.ts | 9 --------- 2 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 src/utilities.ts diff --git a/src/editorDecorator.ts b/src/editorDecorator.ts index 05d2f73..ee70f40 100644 --- a/src/editorDecorator.ts +++ b/src/editorDecorator.ts @@ -1,8 +1,15 @@ import * as vscode from "vscode"; -import * as utils from "./utilities"; import * as cm from "./configManager"; import * as models from "./models"; +export function sprintPos(pos: vscode.Position): string { + return `${pos.line + 1}:${pos.character + 1}`; +} + +export function sprintRange(range: vscode.Range): string { + return `[${sprintPos(range.start)}, ${sprintPos(range.end)}]`; +} + export class EditorDecorator { private editor: vscode.TextEditor; private config: models.Config; @@ -76,7 +83,7 @@ export class EditorDecorator { const end = start + match[0].length; const range = new vscode.Range(this.editor.document.positionAt(start), this.editor.document.positionAt(end)); if (this.doBracesMatch(text, start, end)) { - this.logger.appendLine(`${this.filename}: scanning for: ${rule.regex}: found: ${utils.SprintRange(range)}`); + this.logger.appendLine(`${this.filename}: scanning for: ${rule.regex}: found: ${sprintRange(range)}`); ranges.push(range); } }); @@ -87,7 +94,7 @@ export class EditorDecorator { const range = this.editor.document.validateRange( new vscode.Range(new vscode.Position(0, 0), new vscode.Position(2000, 0)), ); - this.logger.appendLine(`${this.filename}: scanning lines: ${utils.SprintRange(range)}`); + this.logger.appendLine(`${this.filename}: scanning lines: ${sprintRange(range)}`); this.matches = new Map() as Map; for (const rule of this.config.rules) { this.matches.set(rule, this.scanForRule(range, rule)); @@ -116,11 +123,11 @@ export class EditorDecorator { for (let i = 1; i < sorted.length; i++) { if (sorted[i].intersection(merging)) { let m = merging; - const before = utils.SprintRange(m); + const before = sprintRange(m); m = sorted[i]; - const after = utils.SprintRange(m); + const after = sprintRange(m); merging = merging.union(sorted[i]); - const mergd = utils.SprintRange(merging); + const mergd = sprintRange(merging); this.logger.appendLine(`${this.filename}: merging ${before} with ${after} to ${mergd}`); } else { merged.push(merging); diff --git a/src/utilities.ts b/src/utilities.ts deleted file mode 100644 index 6ffab14..0000000 --- a/src/utilities.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as vscode from "vscode"; - -export function SprintPos(pos: vscode.Position): string { - return `${pos.line + 1}:${pos.character + 1}`; -} - -export function SprintRange(range: vscode.Range): string { - return `[${SprintPos(range.start)}, ${SprintPos(range.end)}]`; -} From 3938e84e6c7735a330955de677624144420918f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Fri, 8 May 2026 12:45:06 +0300 Subject: [PATCH 2/8] src: updates all log messages to prefix with timestamp. --- src/configManager.ts | 10 +++++++--- src/editorDecorator.ts | 36 ++++++++++++++++++++---------------- src/extension.ts | 8 ++++++-- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/configManager.ts b/src/configManager.ts index 585e459..4e1692f 100644 --- a/src/configManager.ts +++ b/src/configManager.ts @@ -2,6 +2,10 @@ import * as vscode from "vscode"; import * as config from "./config"; import * as models from "./models"; +function now(): string { + return new Date().toISOString(); +} + type ScopeId = string; class Scope { @@ -94,7 +98,7 @@ class Compiler { compile(scope: Scope): models.Config { try { - this.logger.appendLine(`config.Compiler: compiling user config for ${scope}`); + this.logger.appendLine(`${now()} config.Compiler: compiling user config for ${scope}`); const raw = this.reader.read(scope); const rules = this.rules(raw); return { @@ -124,7 +128,7 @@ export class Cache { for(editor: vscode.TextEditor): models.Config { try { const scope = new Scope(editor); - this.logger.appendLine(`config.Manager: requested user config for ${scope}`); + this.logger.appendLine(`${now()} config.Manager: requested user config for ${scope}`); const i = scope.internalize(); let c = this.cache.get(i); if (!c) { @@ -138,7 +142,7 @@ export class Cache { } invalidate() { - this.logger.appendLine("config.Manager: invalidating cache"); + this.logger.appendLine(`${now()} config.Manager: invalidating cache`); this.cache.clear(); } } diff --git a/src/editorDecorator.ts b/src/editorDecorator.ts index ee70f40..90ab6e1 100644 --- a/src/editorDecorator.ts +++ b/src/editorDecorator.ts @@ -2,6 +2,10 @@ import * as vscode from "vscode"; import * as cm from "./configManager"; import * as models from "./models"; +function now(): string { + return new Date().toISOString(); +} + export function sprintPos(pos: vscode.Position): string { return `${pos.line + 1}:${pos.character + 1}`; } @@ -32,7 +36,7 @@ export class EditorDecorator { this.inFocus = true; this.filename = editor.document.fileName.split("/").pop() ?? ""; this.lastUpdateTimestamp = 0; - this.logger.appendLine(`${this.filename}: constructor (enabled: ${enabled})`); + this.logger.appendLine(`${now()} ${this.filename}: constructor (enabled: ${enabled})`); this.config = this.configManager.for(this.editor); this.withConfig(); } @@ -74,7 +78,7 @@ export class EditorDecorator { } private scanForRule(range: vscode.Range, rule: models.Rule): vscode.Range[] { - this.logger.appendLine(`${this.filename}: scanning for: ${rule.regex}`); + this.logger.appendLine(`${now()} ${this.filename}: scanning for: ${rule.regex}`); const ranges: vscode.Range[] = []; const text = this.editor.document.getText(range); Array.from(text.matchAll(rule.regex)).forEach((match) => { @@ -83,7 +87,7 @@ export class EditorDecorator { const end = start + match[0].length; const range = new vscode.Range(this.editor.document.positionAt(start), this.editor.document.positionAt(end)); if (this.doBracesMatch(text, start, end)) { - this.logger.appendLine(`${this.filename}: scanning for: ${rule.regex}: found: ${sprintRange(range)}`); + this.logger.appendLine(`${now()} ${this.filename}: scanning for: ${rule.regex}: found: ${sprintRange(range)}`); ranges.push(range); } }); @@ -94,7 +98,7 @@ export class EditorDecorator { const range = this.editor.document.validateRange( new vscode.Range(new vscode.Position(0, 0), new vscode.Position(2000, 0)), ); - this.logger.appendLine(`${this.filename}: scanning lines: ${sprintRange(range)}`); + this.logger.appendLine(`${now()} ${this.filename}: scanning lines: ${sprintRange(range)}`); this.matches = new Map() as Map; for (const rule of this.config.rules) { this.matches.set(rule, this.scanForRule(range, rule)); @@ -102,7 +106,7 @@ export class EditorDecorator { } private disposeLastDecorations() { - this.logger.appendLine(`${this.filename}: disposing previous decorations`); + this.logger.appendLine(`${now()} ${this.filename}: disposing previous decorations`); if (!this.decoTypes) return; this.editor.setDecorations(this.decoTypes.max, []); this.editor.setDecorations(this.decoTypes.mid, []); @@ -128,7 +132,7 @@ export class EditorDecorator { const after = sprintRange(m); merging = merging.union(sorted[i]); const mergd = sprintRange(merging); - this.logger.appendLine(`${this.filename}: merging ${before} with ${after} to ${mergd}`); + this.logger.appendLine(`${now()} ${this.filename}: merging ${before} with ${after} to ${mergd}`); } else { merged.push(merging); merging = sorted[i]; @@ -171,16 +175,16 @@ export class EditorDecorator { } private decorateEditor() { - this.logger.appendLine(`${this.filename}: decorating...`); + this.logger.appendLine(`${now()} ${this.filename}: decorating...`); const start = Date.now(); if (!this.matches) this.scanForRules(); this.applyNewDecorations(); - this.logger.appendLine(`${this.filename}: decorated (${Date.now() - start}ms)`); + this.logger.appendLine(`${now()} ${this.filename}: decorated (${Date.now() - start}ms)`); } private schedule() { if (!this.enabled) { - this.logger.appendLine(this.filename + ": skipping update because Dim is disabled for this editor"); + this.logger.appendLine(`${now()} ${this.filename}: skipping update because Dim is disabled for this editor`); return; } const period = this.config.updatePeriod; @@ -199,29 +203,29 @@ export class EditorDecorator { } blur() { - this.logger.appendLine(`${this.filename}: blur`); + this.logger.appendLine(`${now()} ${this.filename}: blur`); this.inFocus = false; } focus() { - this.logger.appendLine(`${this.filename}: focus`); + this.logger.appendLine(`${now()} ${this.filename}: focus`); this.inFocus = true; this.schedule(); } contentChange() { - this.logger.appendLine(`${this.filename}: content change`); + this.logger.appendLine(`${now()} ${this.filename}: content change`); this.matches = undefined; this.schedule(); } selectionChange() { - this.logger.appendLine(`${this.filename}: selection change`); + this.logger.appendLine(`${now()} ${this.filename}: selection change`); this.schedule(); } configChange() { - this.logger.appendLine(`${this.filename}: configuration change`); + this.logger.appendLine(`${now()} ${this.filename}: configuration change`); this.config = this.configManager.for(this.editor); this.matches = undefined; this.withConfig(); @@ -229,14 +233,14 @@ export class EditorDecorator { } enable() { - this.logger.appendLine(`${this.filename}: enabling...`); + this.logger.appendLine(`${now()} ${this.filename}: enabling...`); this.enabled = true; this.matches = undefined; this.schedule(); } disable() { - this.logger.appendLine(`${this.filename}: disabling...`); + this.logger.appendLine(`${now()} ${this.filename}: disabling...`); this.enabled = false; this.disposeLastDecorations(); } diff --git a/src/extension.ts b/src/extension.ts index a0fbade..4a70dd7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -2,6 +2,10 @@ import * as vscode from "vscode"; import { EditorDecorator } from "./editorDecorator"; import { Cache } from "./configManager"; +function now(): string { + return new Date().toISOString(); +} + class ExtensionLifecycleController { decorators: Map; logger: vscode.OutputChannel; @@ -13,7 +17,7 @@ class ExtensionLifecycleController { constructor(context: vscode.ExtensionContext) { this.context = context; this.logger = vscode.window.createOutputChannel("dim"); - this.logger.appendLine("init"); + this.logger.appendLine(`${now()} extension: init`); this.decorators = new Map(); this.config = new Cache(this.logger); this.documentState = new Map(); @@ -83,7 +87,7 @@ class ExtensionLifecycleController { event.document.uri.path === this.activeEditor.document.uri.path && event.document.uri.scheme === "file" ) { - this.logger.appendLine("onDidChangeTextDocument"); + this.logger.appendLine(`${now()} extension: onDidChangeTextDocument`); this.decorators.get(this.activeEditor)?.contentChange(); } } catch (e) { From 0a8c9a78c97d292bfe308f45b741664a89429176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Fri, 8 May 2026 12:49:17 +0300 Subject: [PATCH 3/8] src/editorDecorator: adds missing POI to log lines. --- src/editorDecorator.ts | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/editorDecorator.ts b/src/editorDecorator.ts index 90ab6e1..18c771a 100644 --- a/src/editorDecorator.ts +++ b/src/editorDecorator.ts @@ -36,7 +36,7 @@ export class EditorDecorator { this.inFocus = true; this.filename = editor.document.fileName.split("/").pop() ?? ""; this.lastUpdateTimestamp = 0; - this.logger.appendLine(`${now()} ${this.filename}: constructor (enabled: ${enabled})`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: constructor (enabled: ${enabled})`); this.config = this.configManager.for(this.editor); this.withConfig(); } @@ -78,7 +78,7 @@ export class EditorDecorator { } private scanForRule(range: vscode.Range, rule: models.Rule): vscode.Range[] { - this.logger.appendLine(`${now()} ${this.filename}: scanning for: ${rule.regex}`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: scanning for: ${rule.regex}`); const ranges: vscode.Range[] = []; const text = this.editor.document.getText(range); Array.from(text.matchAll(rule.regex)).forEach((match) => { @@ -87,7 +87,9 @@ export class EditorDecorator { const end = start + match[0].length; const range = new vscode.Range(this.editor.document.positionAt(start), this.editor.document.positionAt(end)); if (this.doBracesMatch(text, start, end)) { - this.logger.appendLine(`${now()} ${this.filename}: scanning for: ${rule.regex}: found: ${sprintRange(range)}`); + this.logger.appendLine( + `${now()} editorDecorator: ${this.filename}: scanning for: ${rule.regex}: found: ${sprintRange(range)}`, + ); ranges.push(range); } }); @@ -98,7 +100,7 @@ export class EditorDecorator { const range = this.editor.document.validateRange( new vscode.Range(new vscode.Position(0, 0), new vscode.Position(2000, 0)), ); - this.logger.appendLine(`${now()} ${this.filename}: scanning lines: ${sprintRange(range)}`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: scanning lines: ${sprintRange(range)}`); this.matches = new Map() as Map; for (const rule of this.config.rules) { this.matches.set(rule, this.scanForRule(range, rule)); @@ -106,7 +108,7 @@ export class EditorDecorator { } private disposeLastDecorations() { - this.logger.appendLine(`${now()} ${this.filename}: disposing previous decorations`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: disposing previous decorations`); if (!this.decoTypes) return; this.editor.setDecorations(this.decoTypes.max, []); this.editor.setDecorations(this.decoTypes.mid, []); @@ -132,7 +134,9 @@ export class EditorDecorator { const after = sprintRange(m); merging = merging.union(sorted[i]); const mergd = sprintRange(merging); - this.logger.appendLine(`${now()} ${this.filename}: merging ${before} with ${after} to ${mergd}`); + this.logger.appendLine( + `${now()} editorDecorator: ${this.filename}: merging ${before} with ${after} to ${mergd}`, + ); } else { merged.push(merging); merging = sorted[i]; @@ -175,16 +179,18 @@ export class EditorDecorator { } private decorateEditor() { - this.logger.appendLine(`${now()} ${this.filename}: decorating...`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: decorating...`); const start = Date.now(); if (!this.matches) this.scanForRules(); this.applyNewDecorations(); - this.logger.appendLine(`${now()} ${this.filename}: decorated (${Date.now() - start}ms)`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: decorated (${Date.now() - start}ms)`); } private schedule() { if (!this.enabled) { - this.logger.appendLine(`${now()} ${this.filename}: skipping update because Dim is disabled for this editor`); + this.logger.appendLine( + `${now()} editorDecorator: ${this.filename}: skipping update because Dim is disabled for this editor`, + ); return; } const period = this.config.updatePeriod; @@ -203,29 +209,29 @@ export class EditorDecorator { } blur() { - this.logger.appendLine(`${now()} ${this.filename}: blur`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: blur`); this.inFocus = false; } focus() { - this.logger.appendLine(`${now()} ${this.filename}: focus`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: focus`); this.inFocus = true; this.schedule(); } contentChange() { - this.logger.appendLine(`${now()} ${this.filename}: content change`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: content change`); this.matches = undefined; this.schedule(); } selectionChange() { - this.logger.appendLine(`${now()} ${this.filename}: selection change`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: selection change`); this.schedule(); } configChange() { - this.logger.appendLine(`${now()} ${this.filename}: configuration change`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: configuration change`); this.config = this.configManager.for(this.editor); this.matches = undefined; this.withConfig(); @@ -233,14 +239,14 @@ export class EditorDecorator { } enable() { - this.logger.appendLine(`${now()} ${this.filename}: enabling...`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: enabling...`); this.enabled = true; this.matches = undefined; this.schedule(); } disable() { - this.logger.appendLine(`${now()} ${this.filename}: disabling...`); + this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: disabling...`); this.enabled = false; this.disposeLastDecorations(); } From 0e1adb3b4e252431c344a96b83b9518d718e4ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Fri, 8 May 2026 13:02:54 +0300 Subject: [PATCH 4/8] src/extension.ts: adds to log missed lifecycle event listeners calls. --- src/extension.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 4a70dd7..619fb10 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -56,6 +56,7 @@ class ExtensionLifecycleController { this.activeEditor = undefined; return; } + this.logger.appendLine(`${now()} extension: onDidChangeActiveTextEditor: ${editor?.document?.uri?.toString()}`); if (this.activeEditor && editor === this.activeEditor) return; @@ -87,7 +88,7 @@ class ExtensionLifecycleController { event.document.uri.path === this.activeEditor.document.uri.path && event.document.uri.scheme === "file" ) { - this.logger.appendLine(`${now()} extension: onDidChangeTextDocument`); + this.logger.appendLine(`${now()} extension: onDidChangeTextDocument: ${event?.reason}`); this.decorators.get(this.activeEditor)?.contentChange(); } } catch (e) { @@ -96,6 +97,7 @@ class ExtensionLifecycleController { } onDidChangeConfiguration(e: vscode.ConfigurationChangeEvent) { + this.logger.appendLine(`${now()} extension: onDidChangeConfiguration: ${e?.affectsConfiguration}`); try { if (e.affectsConfiguration("dim")) { this.config.invalidate(); @@ -109,6 +111,7 @@ class ExtensionLifecycleController { } onCommandReceiveDisableDimForCurrentEditor() { + this.logger.appendLine(`${now()} extension: disableDimForCurrentEditor`); try { if (this.activeEditor) { const ad = this.decorators.get(this.activeEditor); @@ -126,6 +129,7 @@ class ExtensionLifecycleController { } onCommandReceiveEnableDimForCurrentEditor() { + this.logger.appendLine(`${now()} extension: enableDimForCurrentEditor`); try { if (this.activeEditor) { const ad = this.decorators.get(this.activeEditor); @@ -140,6 +144,7 @@ class ExtensionLifecycleController { } onCommandReceiveToggleDimForCurrentEditor() { + this.logger.appendLine(`${now()} extension: toggleDimForCurrentEditor`); try { if (!this.activeEditor) return; const ad = this.decorators.get(this.activeEditor); @@ -155,6 +160,7 @@ class ExtensionLifecycleController { onDidChangeTextEditorSelection(event: vscode.TextEditorSelectionChangeEvent) { try { if (this.activeEditor && this.activeEditor === event.textEditor) { + this.logger.appendLine(`${now()} extension: change selections: ${event?.kind}/${event?.selections?.length}`); this.decorators.get(this.activeEditor)?.selectionChange(); } } catch (e) { @@ -163,6 +169,7 @@ class ExtensionLifecycleController { } destroy() { + this.logger.appendLine(`${now()} extension: destroy`); try { for (const editor of vscode.window.visibleTextEditors) { this.decorators.get(editor)?.disable(); From 36bcd9e274bac44ca1f2dc296c4265bf5ff90697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Fri, 8 May 2026 13:07:01 +0300 Subject: [PATCH 5/8] src/editorDecorator: changes the logging of match-merging for less pollution. --- src/editorDecorator.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/editorDecorator.ts b/src/editorDecorator.ts index 18c771a..cbd613e 100644 --- a/src/editorDecorator.ts +++ b/src/editorDecorator.ts @@ -117,6 +117,7 @@ export class EditorDecorator { private mergeIntersecting(queue: vscode.Range[]): vscode.Range[] { if (queue.length <= 1) return queue; + this.logger.appendLine(`${now()} editorDecorator: merging ${queue.length} matches...`); const sorted = queue.sort((a, b) => { if (a.end.isBeforeOrEqual(b.start)) return -1; // no overlap: aabb if (b.end.isBeforeOrEqual(a.start)) return 1; // no overlap: bbaa @@ -127,22 +128,13 @@ export class EditorDecorator { const merged = [] as vscode.Range[]; let merging = sorted[0]; for (let i = 1; i < sorted.length; i++) { - if (sorted[i].intersection(merging)) { - let m = merging; - const before = sprintRange(m); - m = sorted[i]; - const after = sprintRange(m); - merging = merging.union(sorted[i]); - const mergd = sprintRange(merging); - this.logger.appendLine( - `${now()} editorDecorator: ${this.filename}: merging ${before} with ${after} to ${mergd}`, - ); - } else { + if (!sorted[i].intersection(merging)) { merged.push(merging); merging = sorted[i]; } } merged.push(merging); + this.logger.appendLine(`${now()} editorDecorator: merged to ${merged.length} matches`); return merged; } From 34a247c9d6174ff8691c53aff8378f7bc87e6cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Fri, 8 May 2026 16:24:43 +0300 Subject: [PATCH 6/8] src/editorDecorator: standardizes log message prefixes. --- src/editorDecorator.ts | 46 ++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/editorDecorator.ts b/src/editorDecorator.ts index cbd613e..11f5e68 100644 --- a/src/editorDecorator.ts +++ b/src/editorDecorator.ts @@ -36,11 +36,15 @@ export class EditorDecorator { this.inFocus = true; this.filename = editor.document.fileName.split("/").pop() ?? ""; this.lastUpdateTimestamp = 0; - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: constructor (enabled: ${enabled})`); + this.log(`constructor (enabled: ${enabled})`); this.config = this.configManager.for(this.editor); this.withConfig(); } + private log(message: string) { + this.logger.appendLine(`${now()} editorDecorator(${this.filename}): ${message}`); + } + private withConfig() { if (this.decoTypes) this.disposeLastDecorations(); this.decoTypes = { @@ -78,7 +82,7 @@ export class EditorDecorator { } private scanForRule(range: vscode.Range, rule: models.Rule): vscode.Range[] { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: scanning for: ${rule.regex}`); + this.log(`scanning for: ${rule.regex}...`); const ranges: vscode.Range[] = []; const text = this.editor.document.getText(range); Array.from(text.matchAll(rule.regex)).forEach((match) => { @@ -86,13 +90,9 @@ export class EditorDecorator { const start = match.index; const end = start + match[0].length; const range = new vscode.Range(this.editor.document.positionAt(start), this.editor.document.positionAt(end)); - if (this.doBracesMatch(text, start, end)) { - this.logger.appendLine( - `${now()} editorDecorator: ${this.filename}: scanning for: ${rule.regex}: found: ${sprintRange(range)}`, - ); - ranges.push(range); - } + if (this.doBracesMatch(text, start, end)) ranges.push(range); }); + this.log(`found: ${ranges.map(sprintRange).join(", ")}`); return ranges; } @@ -100,7 +100,7 @@ export class EditorDecorator { const range = this.editor.document.validateRange( new vscode.Range(new vscode.Position(0, 0), new vscode.Position(2000, 0)), ); - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: scanning lines: ${sprintRange(range)}`); + this.log(`scanning lines: ${sprintRange(range)}`); this.matches = new Map() as Map; for (const rule of this.config.rules) { this.matches.set(rule, this.scanForRule(range, rule)); @@ -108,7 +108,7 @@ export class EditorDecorator { } private disposeLastDecorations() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: disposing previous decorations`); + this.log(`disposing previous decorations`); if (!this.decoTypes) return; this.editor.setDecorations(this.decoTypes.max, []); this.editor.setDecorations(this.decoTypes.mid, []); @@ -117,7 +117,7 @@ export class EditorDecorator { private mergeIntersecting(queue: vscode.Range[]): vscode.Range[] { if (queue.length <= 1) return queue; - this.logger.appendLine(`${now()} editorDecorator: merging ${queue.length} matches...`); + this.log(`merging ${queue.length} matches...`); const sorted = queue.sort((a, b) => { if (a.end.isBeforeOrEqual(b.start)) return -1; // no overlap: aabb if (b.end.isBeforeOrEqual(a.start)) return 1; // no overlap: bbaa @@ -134,7 +134,7 @@ export class EditorDecorator { } } merged.push(merging); - this.logger.appendLine(`${now()} editorDecorator: merged to ${merged.length} matches`); + this.log(`merged to ${merged.length}`); return merged; } @@ -171,18 +171,16 @@ export class EditorDecorator { } private decorateEditor() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: decorating...`); + this.log(`decorating...`); const start = Date.now(); if (!this.matches) this.scanForRules(); this.applyNewDecorations(); - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: decorated (${Date.now() - start}ms)`); + this.log(`decorated (${Date.now() - start}ms)`); } private schedule() { if (!this.enabled) { - this.logger.appendLine( - `${now()} editorDecorator: ${this.filename}: skipping update because Dim is disabled for this editor`, - ); + this.log(`skipping update because Dim is disabled for this editor`); return; } const period = this.config.updatePeriod; @@ -201,29 +199,29 @@ export class EditorDecorator { } blur() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: blur`); + this.log(`blur`); this.inFocus = false; } focus() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: focus`); + this.log(`focus`); this.inFocus = true; this.schedule(); } contentChange() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: content change`); + this.log(`content change`); this.matches = undefined; this.schedule(); } selectionChange() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: selection change`); + this.log(`selection change`); this.schedule(); } configChange() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: configuration change`); + this.log(`configuration change`); this.config = this.configManager.for(this.editor); this.matches = undefined; this.withConfig(); @@ -231,14 +229,14 @@ export class EditorDecorator { } enable() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: enabling...`); + this.log(`enabling...`); this.enabled = true; this.matches = undefined; this.schedule(); } disable() { - this.logger.appendLine(`${now()} editorDecorator: ${this.filename}: disabling...`); + this.log(`disabling...`); this.enabled = false; this.disposeLastDecorations(); } From f6f6b5bb7c9891915df60e382909c6d895675a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Sat, 9 May 2026 10:26:06 +0300 Subject: [PATCH 7/8] changelog.md: adds entry for next release. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6757e7f..bf8ce99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 4.0.2 + +**Changed** + +- Refined the logging for granularity and reach. ([#60](https://github.com/ufukty/dim/issues/60)) + ## 4.0.1 **Changed** From bf31f82d69614006d9473b003f7682984c77d77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ufuktan=20Y=C4=B1ld=C4=B1r=C4=B1m?= <13807261+ufukty@users.noreply.github.com> Date: Sat, 9 May 2026 10:26:36 +0300 Subject: [PATCH 8/8] package.json: updates for the next release. --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2fb4a35..f90a813 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dim", - "version": "4.0.1", + "version": "4.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dim", - "version": "4.0.1", + "version": "4.0.2", "devDependencies": { "@eslint/js": "^10.0.1", "@types/node": "^25.3.2", diff --git a/package.json b/package.json index 154874b..5b4225b 100644 --- a/package.json +++ b/package.json @@ -151,5 +151,5 @@ "test": "npx vitest run", "vscode:prepublish": "npx tsc --noEmit && npx eslint src && node esbuild.mjs --production" }, - "version": "4.0.1" + "version": "4.0.2" } \ No newline at end of file