mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Set global user preferences on updatePaths
https://github.com/Microsoft/TypeScript/issues/25739
This commit is contained in:
parent
21bb402655
commit
01989b1c67
|
@ -61,16 +61,24 @@ export default class FileConfigurationManager {
|
|||
document: vscode.TextDocument,
|
||||
token: vscode.CancellationToken
|
||||
): Promise<void> {
|
||||
const editor = vscode.window.visibleTextEditors.find(editor => editor.document.fileName === document.fileName);
|
||||
if (editor) {
|
||||
const formattingOptions = {
|
||||
tabSize: editor.options.tabSize,
|
||||
insertSpaces: editor.options.insertSpaces
|
||||
} as vscode.FormattingOptions;
|
||||
const formattingOptions = this.getFormattingOptions(document);
|
||||
if (formattingOptions) {
|
||||
return this.ensureConfigurationOptions(document, formattingOptions, token);
|
||||
}
|
||||
}
|
||||
|
||||
private getFormattingOptions(
|
||||
document: vscode.TextDocument
|
||||
): vscode.FormattingOptions | undefined {
|
||||
const editor = vscode.window.visibleTextEditors.find(editor => editor.document.fileName === document.fileName);
|
||||
return editor
|
||||
? {
|
||||
tabSize: editor.options.tabSize,
|
||||
insertSpaces: editor.options.insertSpaces
|
||||
} as vscode.FormattingOptions
|
||||
: undefined;
|
||||
}
|
||||
|
||||
public async ensureConfigurationOptions(
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions,
|
||||
|
@ -95,6 +103,22 @@ export default class FileConfigurationManager {
|
|||
await this.client.execute('configure', args, token);
|
||||
}
|
||||
|
||||
public async setGlobalConfigurationFromDocument(
|
||||
document: vscode.TextDocument,
|
||||
token: vscode.CancellationToken,
|
||||
): Promise<void> {
|
||||
const formattingOptions = this.getFormattingOptions(document);
|
||||
if (!formattingOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
const args: Proto.ConfigureRequestArguments = {
|
||||
file: undefined /*global*/,
|
||||
...this.getFileOptions(document, formattingOptions),
|
||||
};
|
||||
await this.client.execute('configure', args, token);
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this.formatOptions.clear();
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ class UpdateImportsOnFileRenameHandler {
|
|||
newFile: string,
|
||||
) {
|
||||
const isDirectoryRename = fs.lstatSync(newFile).isDirectory();
|
||||
await this.fileConfigurationManager.ensureConfigurationForDocument(document, nulToken);
|
||||
await this.fileConfigurationManager.setGlobalConfigurationFromDocument(document, nulToken);
|
||||
|
||||
const args: Proto.GetEditsForFileRenameRequestArgs & { file: string } = {
|
||||
file: targetResource,
|
||||
|
|
Loading…
Reference in a new issue