fix: send user preferences to TS server even without visible editor

When ensureConfigurationForDocument is called and no visible text editor
is found for the document, getFormattingOptions returns undefined and
the method returns early without sending any configuration including
user preferences like preferTypeOnlyAutoImports to the TS server.

This causes source.addMissingImports to ignore the user's
preferTypeOnlyAutoImports setting.

Fix by falling back to undefined formatting options when no visible
editor is found, ensuring user preferences are always sent.

Closes #272479
This commit is contained in:
yogeshwaran-c
2026-03-26 06:43:52 +05:30
parent c2e1f3bef2
commit ef6d5f314e

View File

@@ -53,10 +53,9 @@ export default class FileConfigurationManager extends Disposable {
document: vscode.TextDocument,
token: vscode.CancellationToken
): Promise<void> {
const formattingOptions = this.getFormattingOptions(document);
if (formattingOptions) {
return this.ensureConfigurationOptions(document, formattingOptions, token);
}
const formattingOptions = this.getFormattingOptions(document)
?? { tabSize: undefined, insertSpaces: undefined };
return this.ensureConfigurationOptions(document, formattingOptions, token);
}
private getFormattingOptions(document: vscode.TextDocument): FormattingOptions | undefined {