From e09974f08f43a011b230769bbe1fcbc11d7491f2 Mon Sep 17 00:00:00 2001 From: ipcjs Date: Fri, 1 Dec 2023 01:43:35 +0800 Subject: [PATCH] fix: annotations was misplaced, when opening a historical version of a file (#1) --- src/core/KeyDetector.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/KeyDetector.ts b/src/core/KeyDetector.ts index 945ad77d..f02635bd 100644 --- a/src/core/KeyDetector.ts +++ b/src/core/KeyDetector.ts @@ -83,7 +83,7 @@ export class KeyDetector { static init(ctx: ExtensionContext) { workspace.onDidChangeTextDocument( (e) => { - delete this._get_keys_cache[e.document.uri.fsPath] + delete this._get_keys_cache[e.document.uri.toString(true)] }, null, ctx.subscriptions, @@ -96,10 +96,12 @@ export class KeyDetector { let text = '' let rewriteContext: RewriteKeyContext| undefined let filepath = '' + let cacheKey = '' if (typeof document !== 'string') { filepath = document.uri.fsPath - if (this._get_keys_cache[filepath]) - return this._get_keys_cache[filepath] + cacheKey = document.uri.toString(true) + if (this._get_keys_cache[cacheKey]) + return this._get_keys_cache[cacheKey] regs = regs ?? Global.getUsageMatchRegex(document.languageId, filepath) text = document.getText() @@ -114,8 +116,8 @@ export class KeyDetector { } const keys = regexFindKeys(text, regs, dotEnding, rewriteContext, scopes) - if (filepath) - this._get_keys_cache[filepath] = keys + if (cacheKey) + this._get_keys_cache[cacheKey] = keys return keys }