提交 a87b3967 编写于 作者: E Erich Gamma

FIxing #48806 npm.enableScriptExplorer requires reloading the window

上级 2018ae3a
......@@ -14,4 +14,4 @@ For more information about auto detection of Tasks pls see the [documentation](h
- `npm.runSilent` run npm script with the `--silent` option, the default is `false`.
- `npm.packageManager` the package manager used to run the scripts: `npm` or `yarn`, the default is `npm`.
- `npm.exclude` glob patterns for folders that should be excluded from automatic script detection. The pattern is matched against the **absolute path** of the package.json. For example, to exclude all test folders use '**/test/**'.
- `npm.enableScriptExplorer` enable an explorer view for npm scripts when the workspace contains a 'package.json' file.
- `npm.enableScriptExplorer` enable an explorer view for npm scripts.
......@@ -30,8 +30,7 @@
"activationEvents": [
"onCommand:workbench.action.tasks.runTask",
"onLanguage:json",
"onView:npm",
"workspaceContains:**/package.json"
"onView:npm"
],
"contributes": {
"views": {
......@@ -39,7 +38,7 @@
{
"id": "npm",
"name": "%view.name%",
"when": "hasNpmScripts"
"when": "showExplorer"
}
]
},
......
......@@ -5,7 +5,7 @@
"config.npm.runSilent": "Run npm commands with the `--silent` option.",
"config.npm.packageManager": "The package manager used to run scripts.",
"config.npm.exclude": "Configure glob patterns for folders that should be excluded from automatic script detection.",
"config.npm.enableScriptExplorer": "Enable an explorer view for npm scripts, when the workspace contains a 'package.json' file.",
"config.npm.enableScriptExplorer": "Enable an explorer view for npm scripts.",
"npm.parseError": "Npm task detection: failed to parse the file {0}",
"taskdef.script": "The npm script to customize.",
"taskdef.path": "The path to the folder of the package.json file that provides the script. Can be ommitted.",
......
......@@ -9,7 +9,7 @@ import * as vscode from 'vscode';
import { addJSONProviders } from './features/jsonContributions';
import { NpmScriptsTreeDataProvider } from './npmView';
import { provideNpmScripts, hasNpmScripts, explorerIsEnabled } from './tasks';
import { provideNpmScripts, explorerIsEnabled } from './tasks';
let taskProvider: vscode.Disposable | undefined;
......@@ -17,7 +17,12 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
taskProvider = registerTaskProvider();
registerExplorer(context);
configureHttpRequest();
vscode.workspace.onDidChangeConfiguration(() => configureHttpRequest());
vscode.workspace.onDidChangeConfiguration((e) => {
configureHttpRequest();
if (e.affectsConfiguration('npm.enableScriptExplorer')) {
updateExplorerVisibility();
}
});
context.subscriptions.push(addJSONProviders(httpRequest.xhr));
}
......@@ -36,14 +41,16 @@ function registerTaskProvider(): vscode.Disposable | undefined {
return undefined;
}
function updateExplorerVisibility() {
vscode.commands.executeCommand('setContext', 'showExplorer', explorerIsEnabled());
}
async function registerExplorer(context: vscode.ExtensionContext) {
if (explorerIsEnabled() && vscode.workspace.workspaceFolders) {
if (vscode.workspace.workspaceFolders) {
let treeDataProvider = vscode.window.registerTreeDataProvider('npm', new NpmScriptsTreeDataProvider(context));
context.subscriptions.push(treeDataProvider);
if (await hasNpmScripts()) {
vscode.commands.executeCommand('setContext', 'hasNpmScripts', true);
}
}
updateExplorerVisibility();
}
function configureHttpRequest() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册