Skip to content

Commit bf0aa48

Browse files
committed
Fix indentation in XML/XSD files
Make sure to upcast `string|DocumentFilter` correctly when setting indentation rules. Fixes #899
1 parent 21269ee commit bf0aa48

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/extension.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
*/
1212

1313
import * as fs from 'fs-extra';
14-
import * as os from 'os';
15-
import * as path from 'path';
16-
import { ExtensionContext, Uri, extensions, languages, commands } from "vscode";
14+
import { DocumentFilter, DocumentSelector, ExtensionContext, Uri, commands, extensions, languages } from "vscode";
1715
import { Executable, LanguageClient } from 'vscode-languageclient/node';
1816
import { XMLExtensionApi } from './api/xmlExtensionApi';
1917
import { getXmlExtensionApiImplementation } from './api/xmlExtensionApiImplementation';
2018
import { cleanUpHeapDumps } from './client/clientErrorHandler';
2119
import { getIndentationRules } from './client/indentation';
22-
import { startLanguageClient, XML_SUPPORTED_LANGUAGE_IDS } from './client/xmlClient';
20+
import { XML_SUPPORTED_LANGUAGE_IDS, startLanguageClient } from './client/xmlClient';
2321
import { registerClientOnlyCommands } from './commands/registerCommands';
2422
import { collectXmlJavaExtensions } from './plugin';
2523
import * as requirements from './server/requirements';
@@ -37,8 +35,13 @@ export async function activate(context: ExtensionContext): Promise<XMLExtensionA
3735
registerClientOnlyCommands(context);
3836

3937
// Update indentation rules for all language which are XML.
40-
XML_SUPPORTED_LANGUAGE_IDS.forEach(l => {
41-
const languageId = <string> l;
38+
XML_SUPPORTED_LANGUAGE_IDS.forEach((l: DocumentSelector) => {
39+
let languageId: string;
40+
if ((l as DocumentFilter).language) {
41+
languageId = (l as DocumentFilter).language;
42+
} else {
43+
languageId = l as string;
44+
}
4245
languages.setLanguageConfiguration(languageId, getIndentationRules());
4346
});
4447

0 commit comments

Comments
 (0)