mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Flush scripts cache when the document changes
This commit is contained in:
parent
62ba096511
commit
7697ef6711
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue