提交 7697ef67 编写于 作者: E Erich Gamma

Flush scripts cache when the document changes

上级 62ba0965
......@@ -17,7 +17,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const hoverProvider = registerHoverProvider(context);
configureHttpRequest();
vscode.workspace.onDidChangeConfiguration((e) => {
let d = vscode.workspace.onDidChangeConfiguration((e) => {
configureHttpRequest();
if (e.affectsConfiguration('npm.exclude')) {
invalidateTasksCache();
......@@ -31,6 +31,13 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
}
});
context.subscriptions.push(d);
d = vscode.workspace.onDidChangeTextDocument((e) => {
invalidateHoverScriptsCache(e.document);
});
context.subscriptions.push(d);
context.subscriptions.push(addJSONProviders(httpRequest.xhr));
}
......
......@@ -18,8 +18,14 @@ const localize = nls.loadMessageBundle();
let cachedDocument: Uri | undefined = undefined;
let cachedScriptsMap: Map<string, [number, number, string]> | undefined = undefined;
export function invalidateHoverScriptsCache() {
cachedDocument = undefined;
export function invalidateHoverScriptsCache(document?: TextDocument) {
if (!document) {
cachedDocument = undefined;
return;
}
if (document.uri === cachedDocument) {
cachedDocument = undefined;
}
}
export class NpmScriptHoverProvider implements HoverProvider {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册