Skip to content

Commit 57581be

Browse files
autoClosingBrackets are forced off if autoCloseTags is enabled
Signed-off-by: Nikolas Komonen <nikolaskomonen@gmail.com>
1 parent 022d05b commit 57581be

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
"scope": "window"
151151
}
152152
}
153+
},
154+
"configurationDefaults": {
155+
"[xml]": {
156+
"editor.autoClosingBrackets": "never"
157+
}
153158
}
154159
}
155160
}

src/extension.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { languages, IndentAction, workspace, window, commands, ExtensionContext,
1717
import * as path from 'path';
1818
import * as os from 'os';
1919
import { activateTagClosing } from './tagClosing';
20-
2120
namespace TagCloseRequest {
2221
export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('xml/closeTag');
2322
}
@@ -45,11 +44,12 @@ export function activate(context: ExtensionContext) {
4544
revealOutputChannelOn: RevealOutputChannelOn.Never,
4645
initializationOptions: { settings: getSettings() },
4746
synchronize: {
48-
configurationSection: ['xml']
47+
configurationSection: ['xml', '[xml]']
4948
},
5049
middleware: {
5150
workspace: {
5251
didChangeConfiguration: () => languageClient.sendNotification(DidChangeConfigurationNotification.type, { settings: getSettings() })
52+
5353
}
5454
}
5555
}
@@ -75,6 +75,17 @@ export function activate(context: ExtensionContext) {
7575

7676
function getSettings(): JSON {
7777
let configXML = workspace.getConfiguration();
78+
79+
let autoCloseTags = configXML.get("xml.completion.autoCloseTags");
80+
let autoClosingBrackets = configXML.get("[xml]")["editor.autoClosingBrackets"];
81+
if (autoCloseTags && autoClosingBrackets != "never") {
82+
window.showInformationMessage("Since xml.completion.autoCloseTags is enabled, [xml].editor.autoClosingBrackets was set to 'never'.");
83+
workspace.getConfiguration().update("[xml]", { "editor.autoClosingBrackets": "never" }, true).then(
84+
() => console.log("testSetting" + ' globally set to ' + "false"),
85+
(error) => console.log(error)
86+
);
87+
}
88+
7889
configXML = configXML.get('xml');
7990
let settings: JSON;
8091
if (!configXML) {
@@ -86,7 +97,7 @@ export function activate(context: ExtensionContext) {
8697
client: true
8798
},
8899
format: {
89-
enabled : true,
100+
enabled: true,
90101
splitAttributes: false
91102
},
92103
completion: {
@@ -102,11 +113,8 @@ export function activate(context: ExtensionContext) {
102113
settings['logs']['file'] = logfile;
103114
return settings;
104115
}
105-
106-
107-
108-
109116
}
117+
110118
function getIndentationRules(): LanguageConfiguration {
111119
return {
112120
onEnterRules: [

0 commit comments

Comments
 (0)