chore(vscode): update to 1.54.2
This commit is contained in:
@@ -3,20 +3,24 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import {
|
||||
ExtensionContext, TextDocument, commands, ProviderResult, CancellationToken,
|
||||
workspace, tasks, Range, HoverProvider, Hover, Position, MarkdownString, Uri
|
||||
} from 'vscode';
|
||||
import {
|
||||
createTask, startDebugging, findAllScriptRanges
|
||||
} from './tasks';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { dirname } from 'path';
|
||||
import {
|
||||
CancellationToken, commands, ExtensionContext,
|
||||
Hover, HoverProvider, MarkdownString, Position, ProviderResult,
|
||||
tasks, TextDocument,
|
||||
Uri, workspace
|
||||
} from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { INpmScriptInfo, readScripts } from './readScripts';
|
||||
import {
|
||||
createTask,
|
||||
getPackageManager, startDebugging
|
||||
} from './tasks';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
let cachedDocument: Uri | undefined = undefined;
|
||||
let cachedScriptsMap: Map<string, [number, number, string]> | undefined = undefined;
|
||||
let cachedScripts: INpmScriptInfo | undefined = undefined;
|
||||
|
||||
export function invalidateHoverScriptsCache(document?: TextDocument) {
|
||||
if (!document) {
|
||||
@@ -42,20 +46,16 @@ export class NpmScriptHoverProvider implements HoverProvider {
|
||||
let hover: Hover | undefined = undefined;
|
||||
|
||||
if (!cachedDocument || cachedDocument.fsPath !== document.uri.fsPath) {
|
||||
cachedScriptsMap = findAllScriptRanges(document.getText());
|
||||
cachedScripts = readScripts(document);
|
||||
cachedDocument = document.uri;
|
||||
}
|
||||
|
||||
cachedScriptsMap!.forEach((value, key) => {
|
||||
let start = document.positionAt(value[0]);
|
||||
let end = document.positionAt(value[0] + value[1]);
|
||||
let range = new Range(start, end);
|
||||
|
||||
if (range.contains(position)) {
|
||||
cachedScripts?.scripts.forEach(({ name, nameRange }) => {
|
||||
if (nameRange.contains(position)) {
|
||||
let contents: MarkdownString = new MarkdownString();
|
||||
contents.isTrusted = true;
|
||||
contents.appendMarkdown(this.createRunScriptMarkdown(key, document.uri));
|
||||
contents.appendMarkdown(this.createDebugScriptMarkdown(key, document.uri));
|
||||
contents.appendMarkdown(this.createRunScriptMarkdown(name, document.uri));
|
||||
contents.appendMarkdown(this.createDebugScriptMarkdown(name, document.uri));
|
||||
hover = new Hover(contents);
|
||||
}
|
||||
});
|
||||
@@ -103,7 +103,7 @@ export class NpmScriptHoverProvider implements HoverProvider {
|
||||
let documentUri = args.documentUri;
|
||||
let folder = workspace.getWorkspaceFolder(documentUri);
|
||||
if (folder) {
|
||||
let task = await createTask(this.context, script, ['run', script], folder, documentUri);
|
||||
let task = await createTask(await getPackageManager(this.context, folder.uri), script, ['run', script], folder, documentUri);
|
||||
await tasks.executeTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user