mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
html.format.unformatted does not respect scripts. Fixes #16634
This commit is contained in:
parent
067cf11bf0
commit
8eb0cce438
|
@ -86,7 +86,7 @@
|
|||
"string",
|
||||
"null"
|
||||
],
|
||||
"default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, pre, q, samp, script, select, small, span, strong, sub, sup, textarea, tt, var",
|
||||
"default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, pre, q, samp, select, small, span, strong, sub, sup, textarea, tt, var",
|
||||
"description": "%html.format.unformatted.desc%"
|
||||
},
|
||||
"html.format.indentInnerHtml": {
|
||||
|
|
|
@ -35,6 +35,7 @@ documents.listen(connection);
|
|||
|
||||
let workspacePath: string;
|
||||
var languageModes: LanguageModes;
|
||||
var settings: any = {};
|
||||
|
||||
// After the server has started the client sends an initilize request. The server receives
|
||||
// in the passed params the rootPath of the workspace plus the client capabilites
|
||||
|
@ -68,9 +69,10 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
|
|||
};
|
||||
});
|
||||
|
||||
|
||||
// The settings have changed. Is send on server activation as well.
|
||||
connection.onDidChangeConfiguration((change) => {
|
||||
settings = change.settings;
|
||||
|
||||
languageModes.getAllModes().forEach(m => {
|
||||
if (m.configure) {
|
||||
m.configure(change.settings);
|
||||
|
@ -201,9 +203,12 @@ connection.onDocumentRangeFormatting(formatParams => {
|
|||
let document = documents.get(formatParams.textDocument.uri);
|
||||
let ranges = languageModes.getModesInRange(document, formatParams.range);
|
||||
let result: TextEdit[] = [];
|
||||
let unformattedTags: string = settings && settings.html && settings.html.format && settings.html.format.unformatted || '';
|
||||
let enabledModes = { css: !unformattedTags.match(/\bstyle\b/), javascript: !unformattedTags.match(/\bscript\b/), html: true };
|
||||
ranges.forEach(r => {
|
||||
let mode = r.mode;
|
||||
if (mode && mode.format && !r.attributeValue) {
|
||||
if (mode && mode.format && enabledModes[mode.getId()] && !r.attributeValue) {
|
||||
console.log(mode.getId());
|
||||
let edits = mode.format(document, r, formatParams.options);
|
||||
pushAll(result, edits);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export function getJavascriptMode(documentRegions: LanguageModelCache<HTMLDocume
|
|||
|
||||
return {
|
||||
getId() {
|
||||
return 'html';
|
||||
return 'javascript';
|
||||
},
|
||||
configure(options: any) {
|
||||
settings = options && options.javascript;
|
||||
|
|
Loading…
Reference in a new issue