Skip to content

Commit da64432

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

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-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: 32 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,15 @@ 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: {
52-
didChangeConfiguration: () => languageClient.sendNotification(DidChangeConfigurationNotification.type, { settings: getSettings() })
51+
didChangeConfiguration: () => {
52+
languageClient.sendNotification(DidChangeConfigurationNotification.type, { settings: getSettings() });
53+
verifyConfigurations();
54+
}
55+
5356
}
5457
}
5558
}
@@ -86,7 +89,7 @@ export function activate(context: ExtensionContext) {
8689
client: true
8790
},
8891
format: {
89-
enabled : true,
92+
enabled: true,
9093
splitAttributes: false
9194
},
9295
completion: {
@@ -102,11 +105,33 @@ export function activate(context: ExtensionContext) {
102105
settings['logs']['file'] = logfile;
103106
return settings;
104107
}
108+
}
105109

106-
107-
108-
110+
function verifyConfigurations() {
111+
let configXML = workspace.getConfiguration();
112+
let autoCloseTags = configXML.get("xml.completion.autoCloseTags");
113+
let autoClosingBrackets = configXML.get("[xml]")["editor.autoClosingBrackets"];
114+
if (autoCloseTags && autoClosingBrackets != "never") {
115+
window.showInformationMessage(
116+
"'xml.completion.autoCloseTags' cannot be enabled while '[xml].editor.autoClosingBrackets' does not equal 'never'.",
117+
"autoClosingBrackets = 'never'",
118+
"autoCloseTags = false").then((selection) => {
119+
if(selection == "autoClosingBrackets = 'never'") {
120+
workspace.getConfiguration().update("[xml]", { "editor.autoClosingBrackets": "never" }, true).then(
121+
() => console.log('[xml].editor.autoClosingBrackets globally set to never'),
122+
(error) => console.log(error)
123+
);
124+
}
125+
else if(selection == "autoClosingBrackets = 'never'"){
126+
workspace.getConfiguration("xml.completion").update("autoCloseTags", false, true).then(
127+
() => console.log('xml.completion.autoCloseTags globally set to false'),
128+
(error) => console.log(error)
129+
);
130+
}
131+
});
132+
}
109133
}
134+
110135
function getIndentationRules(): LanguageConfiguration {
111136
return {
112137
onEnterRules: [

0 commit comments

Comments
 (0)