mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 11:49:38 +00:00
[typescript-language-features] Add setting for autoImportFileExcludePatterns (#153160)
* Add setting for autoImportFileExcludePatterns * Add TS 4.8 to message
This commit is contained in:
@@ -983,6 +983,22 @@
|
||||
"markdownDescription": "%typescript.preferences.includePackageJsonAutoImports%",
|
||||
"scope": "window"
|
||||
},
|
||||
"typescript.preferences.autoImportFileExcludePatterns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportFileExcludePatterns%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"javascript.preferences.autoImportFileExcludePatterns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "%typescript.preferences.autoImportFileExcludePatterns%",
|
||||
"scope": "resource"
|
||||
},
|
||||
"javascript.preferences.renameShorthandProperties": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
"typescript.preferences.includePackageJsonAutoImports.auto": "Search dependencies based on estimated performance impact.",
|
||||
"typescript.preferences.includePackageJsonAutoImports.on": "Always search dependencies.",
|
||||
"typescript.preferences.includePackageJsonAutoImports.off": "Never search dependencies.",
|
||||
"typescript.preferences.autoImportFileExcludePatterns": "Specify glob patterns of files to exclude from auto imports. Requires using TypeScript 4.8 or newer in the workspace.",
|
||||
"typescript.updateImportsOnFileMove.enabled": "Enable/disable automatic updating of import paths when you rename or move a file in VS Code.",
|
||||
"typescript.updateImportsOnFileMove.enabled.prompt": "Prompt on each rename.",
|
||||
"typescript.updateImportsOnFileMove.enabled.always": "Always update paths automatically.",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import type * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
@@ -189,6 +190,8 @@ export default class FileConfigurationManager extends Disposable {
|
||||
includeCompletionsWithSnippetText: config.get<boolean>('suggest.includeCompletionsWithSnippetText', true),
|
||||
includeCompletionsWithClassMemberSnippets: config.get<boolean>('suggest.classMemberSnippets.enabled', true),
|
||||
includeCompletionsWithObjectLiteralMethodSnippets: config.get<boolean>('suggest.objectLiteralMethodSnippets.enabled', true),
|
||||
// @ts-expect-error until TS 4.8
|
||||
autoImportFileExcludePatterns: this.getAutoImportFileExcludePatternsPreference(preferencesConfig, vscode.workspace.getWorkspaceFolder(document.uri)?.uri),
|
||||
useLabelDetailsInCompletionEntries: true,
|
||||
allowIncompleteCompletions: true,
|
||||
displayPartsForJSDoc: true,
|
||||
@@ -205,6 +208,18 @@ export default class FileConfigurationManager extends Disposable {
|
||||
default: return this.client.apiVersion.gte(API.v333) ? 'auto' : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private getAutoImportFileExcludePatternsPreference(config: vscode.WorkspaceConfiguration, workspaceFolder: vscode.Uri | undefined): string[] | undefined {
|
||||
return workspaceFolder && config.get<string[]>('autoImportFileExcludePatterns')?.map(p => {
|
||||
// Normalization rules: https://github.com/microsoft/TypeScript/pull/49578
|
||||
const slashNormalized = p.replace(/\\/g, '/');
|
||||
const isRelative = /^\.\.?($|\/)/.test(slashNormalized);
|
||||
return path.isAbsolute(p) ? p :
|
||||
p.startsWith('*') ? '/' + slashNormalized :
|
||||
isRelative ? vscode.Uri.joinPath(workspaceFolder, p).fsPath :
|
||||
'/**/' + slashNormalized;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class InlayHintSettingNames {
|
||||
|
||||
Reference in New Issue
Block a user