Skip to content

Commit a04213f

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

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,19 @@
148148
"default": true,
149149
"description": "Enable/disable ability to autoclose tags. \n\n**IMPORTANT: Turn off editor.autoClosingTags for this to work\n**",
150150
"scope": "window"
151+
},
152+
"xml.completion.testSetting": {
153+
"type": "boolean",
154+
"default": true,
155+
"description": "Enable/disable ability to autoclose tags. \n\n**IMPORTANT: Turn off editor.autoClosingTags for this to work\n**",
156+
"scope": "window"
151157
}
152158
}
159+
},
160+
"configurationDefaults": {
161+
"[xml]": {
162+
"editor.autoClosingBrackets": "never"
163+
}
153164
}
154165
}
155166
}

src/extension.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ 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-
20+
var oldSettings = {};
2121
namespace TagCloseRequest {
2222
export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('xml/closeTag');
2323
}
@@ -45,15 +45,16 @@ export function activate(context: ExtensionContext) {
4545
revealOutputChannelOn: RevealOutputChannelOn.Never,
4646
initializationOptions: { settings: getSettings() },
4747
synchronize: {
48-
configurationSection: ['xml']
48+
configurationSection: ['xml', '[xml]']
4949
},
5050
middleware: {
5151
workspace: {
5252
didChangeConfiguration: () => languageClient.sendNotification(DidChangeConfigurationNotification.type, { settings: getSettings() })
53+
5354
}
5455
}
5556
}
56-
57+
5758
let serverOptions = prepareExecutable(requirements);
5859
let languageClient = new LanguageClient('xml', 'XML Support', serverOptions, clientOptions);
5960
let toDispose = context.subscriptions;
@@ -75,6 +76,17 @@ export function activate(context: ExtensionContext) {
7576

7677
function getSettings(): JSON {
7778
let configXML = workspace.getConfiguration();
79+
80+
let autoCloseTags = configXML.get("xml.completion.autoCloseTags");
81+
let autoClosingBrackets = configXML.get("[xml]")["editor.autoClosingBrackets"];
82+
if(autoCloseTags && autoClosingBrackets != "never") {
83+
window.showInformationMessage("Since xml.completion.autoCloseTags is enabled, [xml].editor.autoClosingBrackets was set to 'never'.");
84+
workspace.getConfiguration().update("[xml]", {"editor.autoClosingBrackets": "never"}, true).then(
85+
() => console.log("testSetting" + ' globally set to ' + "false"),
86+
(error) => console.log(error)
87+
);
88+
}
89+
7890
configXML = configXML.get('xml');
7991
let settings: JSON;
8092
if (!configXML) {
@@ -102,10 +114,6 @@ export function activate(context: ExtensionContext) {
102114
settings['logs']['file'] = logfile;
103115
return settings;
104116
}
105-
106-
107-
108-
109117
}
110118
function getIndentationRules(): LanguageConfiguration {
111119
return {

0 commit comments

Comments
 (0)