Skip to content

Commit

Permalink
fix: annotations was misplaced, when opening a historical version of …
Browse files Browse the repository at this point in the history
…a file (#1)
  • Loading branch information
ipcjs committed Nov 30, 2023
1 parent 114cd7f commit e09974f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/KeyDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand All @@ -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
}

Expand Down

0 comments on commit e09974f

Please sign in to comment.