mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
Allow tsc tasks to be disabled using settings. Fixes #27312
This commit is contained in:
@@ -315,6 +315,15 @@
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%javascript.nameSuggestions%"
|
||||
},
|
||||
"typescript.tsc.autoDetect": {
|
||||
"type": "string",
|
||||
"default": "on",
|
||||
"enum": [
|
||||
"on",
|
||||
"off"
|
||||
],
|
||||
"description": "%typescript.tsc.autoDetect%"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -37,5 +37,6 @@
|
||||
"jsDocCompletion.enabled": "Enable/disable auto JSDoc comments",
|
||||
"javascript.implicitProjectConfig.checkJs": "Enable/disable semantic checking of JavaScript files. Existing jsconfig.json or tsconfig.json files override this setting. Requires TypeScript >=2.3.1.",
|
||||
"typescript.check.npmIsInstalled": "Check if NPM is installed for automatic typings acquisition",
|
||||
"javascript.nameSuggestions": "Enable/disable including unique names from the file in JavaScript suggestion lists."
|
||||
"javascript.nameSuggestions": "Enable/disable including unique names from the file in JavaScript suggestion lists.",
|
||||
"typescript.tsc.autoDetect": "Controls whether auto detection of tsc tasks is on or off."
|
||||
}
|
||||
|
||||
@@ -21,7 +21,10 @@ const exists = (file: string): Promise<boolean> =>
|
||||
});
|
||||
});
|
||||
|
||||
export default class TypeScriptTaskProvider implements vscode.TaskProvider {
|
||||
/**
|
||||
* Provides tasks for building `tsconfig.json` files in a project.
|
||||
*/
|
||||
class TscTaskProvider implements vscode.TaskProvider {
|
||||
private readonly tsconfigProvider: TsConfigProvider;
|
||||
|
||||
public constructor(
|
||||
@@ -116,4 +119,39 @@ export default class TypeScriptTaskProvider implements vscode.TaskProvider {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
type AutoDetect = 'on' | 'off';
|
||||
|
||||
/**
|
||||
* Manages registrations of TypeScript task provides with VScode.
|
||||
*/
|
||||
export default class TypeScriptTaskProviderManager {
|
||||
private taskProviderSub: vscode.Disposable | undefined = undefined;
|
||||
private readonly disposables: vscode.Disposable[] = [];
|
||||
|
||||
constructor(
|
||||
private readonly lazyClient: () => TypeScriptServiceClient
|
||||
) {
|
||||
vscode.workspace.onDidChangeConfiguration(this.onConfigurationChanged, this, this.disposables);
|
||||
this.onConfigurationChanged();
|
||||
}
|
||||
|
||||
dispose() {
|
||||
if (this.taskProviderSub) {
|
||||
this.taskProviderSub.dispose();
|
||||
this.taskProviderSub = undefined;
|
||||
}
|
||||
this.disposables.forEach(x => x.dispose());
|
||||
}
|
||||
|
||||
private onConfigurationChanged() {
|
||||
let autoDetect = vscode.workspace.getConfiguration('typescript.tsc').get<AutoDetect>('autoDetect');
|
||||
if (this.taskProviderSub && autoDetect === 'off') {
|
||||
this.taskProviderSub.dispose();
|
||||
this.taskProviderSub = undefined;
|
||||
} else if (!this.taskProviderSub && autoDetect === 'on') {
|
||||
this.taskProviderSub = vscode.workspace.registerTaskProvider(new TscTaskProvider(this.lazyClient));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ import CodeActionProvider from './features/codeActionProvider';
|
||||
import ReferenceCodeLensProvider from './features/referencesCodeLensProvider';
|
||||
import { JsDocCompletionProvider, TryCompleteJsDocCommand } from './features/jsDocCompletionProvider';
|
||||
import { DirectiveCommentCompletionProvider } from './features/directiveCommentCompletionProvider';
|
||||
import TypeScriptTaskProvider from './features/taskProvider';
|
||||
import TypeScriptTaskProviderManager from './features/taskProvider';
|
||||
|
||||
import ImplementationCodeLensProvider from './features/implementationsCodeLensProvider';
|
||||
|
||||
@@ -131,7 +131,7 @@ export function activate(context: ExtensionContext): void {
|
||||
lazyClientHost().serviceClient.restartTsServer();
|
||||
}));
|
||||
|
||||
context.subscriptions.push(workspace.registerTaskProvider(new TypeScriptTaskProvider(() => lazyClientHost().serviceClient)));
|
||||
context.subscriptions.push(new TypeScriptTaskProviderManager(() => lazyClientHost().serviceClient));
|
||||
|
||||
const goToProjectConfig = (isTypeScript: boolean) => {
|
||||
const editor = window.activeTextEditor;
|
||||
|
||||
Reference in New Issue
Block a user