mirror of
https://github.com/Microsoft/vscode
synced 2024-07-05 01:08:57 +00:00
[typescript-language-features] Fix autoImportFileExcludePatterns format to work on Windows (#202762)
* Do not prefix autoImportFileExcludePatterns with `/` * Fix autoImportFileExcludePatterns format
This commit is contained in:
parent
9697534cc0
commit
d1498b3a48
|
@ -215,12 +215,16 @@ export default class FileConfigurationManager extends Disposable {
|
|||
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);
|
||||
const isRelative = /^\.\.?($|[\/\\])/.test(p);
|
||||
// In TypeScript < 5.3, the first path component cannot be a wildcard, so we need to prefix
|
||||
// it with a path root (e.g. `/` or `c:\`)
|
||||
const wildcardPrefix = this.client.apiVersion.gte(API.v540)
|
||||
? ''
|
||||
: path.parse(this.client.toTsFilePath(workspaceFolder)!).root;
|
||||
return path.isAbsolute(p) ? p :
|
||||
p.startsWith('*') ? '/' + slashNormalized :
|
||||
isRelative ? vscode.Uri.joinPath(workspaceFolder, p).fsPath :
|
||||
'/**/' + slashNormalized;
|
||||
p.startsWith('*') ? wildcardPrefix + p :
|
||||
isRelative ? this.client.toTsFilePath(vscode.Uri.joinPath(workspaceFolder, p))! :
|
||||
wildcardPrefix + '**' + path.sep + p;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
2
src/vscode-dts/vscode.d.ts
vendored
2
src/vscode-dts/vscode.d.ts
vendored
|
@ -1534,7 +1534,7 @@ declare module 'vscode' {
|
|||
* ```ts
|
||||
* const u = URI.parse('file://server/c$/folder/file.txt')
|
||||
* u.authority === 'server'
|
||||
* u.path === '/shares/c$/file.txt'
|
||||
* u.path === '/c$/folder/file.txt'
|
||||
* u.fsPath === '\\server\c$\folder\file.txt'
|
||||
* ```
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user