mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
More type assertion fixes (#230181)
For #211878 Also adds a few suppressions
This commit is contained in:
@@ -19,6 +19,13 @@ interface FileConfiguration {
|
||||
readonly preferences: Proto.UserPreferences;
|
||||
}
|
||||
|
||||
interface FormattingOptions {
|
||||
|
||||
readonly tabSize: number | undefined;
|
||||
|
||||
readonly insertSpaces: boolean | undefined;
|
||||
}
|
||||
|
||||
function areFileConfigurationsEqual(a: FileConfiguration, b: FileConfiguration): boolean {
|
||||
return equals(a, b);
|
||||
}
|
||||
@@ -51,21 +58,21 @@ export default class FileConfigurationManager extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
private getFormattingOptions(document: vscode.TextDocument): FormattingOptions | undefined {
|
||||
const editor = vscode.window.visibleTextEditors.find(editor => editor.document.uri.toString() === document.uri.toString());
|
||||
if (!editor) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
tabSize: typeof editor.options.tabSize === 'number' ? editor.options.tabSize : undefined,
|
||||
insertSpaces: typeof editor.options.insertSpaces === 'boolean' ? editor.options.insertSpaces : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
public async ensureConfigurationOptions(
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions,
|
||||
options: FormattingOptions,
|
||||
token: vscode.CancellationToken
|
||||
): Promise<void> {
|
||||
const file = this.client.toOpenTsFilePath(document);
|
||||
@@ -122,7 +129,7 @@ export default class FileConfigurationManager extends Disposable {
|
||||
|
||||
private getFileOptions(
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions
|
||||
options: FormattingOptions
|
||||
): FileConfiguration {
|
||||
return {
|
||||
formatOptions: this.getFormatOptions(document, options),
|
||||
@@ -132,7 +139,7 @@ export default class FileConfigurationManager extends Disposable {
|
||||
|
||||
private getFormatOptions(
|
||||
document: vscode.TextDocument,
|
||||
options: vscode.FormattingOptions
|
||||
options: FormattingOptions
|
||||
): Proto.FormatCodeSettings {
|
||||
const config = vscode.workspace.getConfiguration(
|
||||
isTypeScriptDocument(document) ? 'typescript.format' : 'javascript.format',
|
||||
|
||||
Reference in New Issue
Block a user