Skip to content

Commit a46651b

Browse files
committed
fix: disabledLanguages are not being disabled
Languages defined in the `disabledLanguages` setting are not being disabled for certain things, and are still being treated as "supported". Disabled languages should not be in any "supported" list, auto or custom supported. Fixed by ensuring in all cases the langId will be ignored if it's set as disabled. - Added `isLangIdDisabled` method calls to all single-line comments and multi-line comments for both auto-supported and custom-supported lists.
1 parent 13cca39 commit a46651b

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

src/configuration.ts

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export class Configuration {
111111

112112
// Setup the auto-supported single-line languages.
113113
for (let [langId, style] of singleLineLangs) {
114+
// If langId isn't disabled...
114115
if (!this.isLangIdDisabled(langId)) {
115116
// Set a bool if the single-line language also supports multi-line comments
116117
// (ie. the single-line language is also present in the multi-line map);
@@ -137,16 +138,20 @@ export class Configuration {
137138

138139
// Setup the custom-supported single-line languages, that are otherwise unsupported.
139140
for (let [langId, style] of customSingleLineLangs) {
140-
// Set a bool if the single-line language also supports multi-line comments
141-
// (ie. the single-line language is also present in the multi-line map);
142-
let multiLine = customMultiLineLangs.includes(langId);
143-
disposables.push(this.setLanguageConfiguration(langId, multiLine, style));
141+
// If the langId isn't set as disabled...
142+
if (!this.isLangIdDisabled(langId)) {
143+
// Set a bool if the single-line language also supports multi-line comments
144+
// (ie. the single-line language is also present in the multi-line map);
145+
let multiLine = customMultiLineLangs.includes(langId);
146+
disposables.push(this.setLanguageConfiguration(langId, multiLine, style));
147+
}
144148
}
145149

146150
// Setup the custom-supported multi-line languages, that are otherwise unsupported.
147151
for (let langId of customMultiLineLangs) {
148-
// If customSingleLineLangs doesn't have the langId
149-
if (!customSingleLineLangs.has(langId)) {
152+
// If customSingleLineLangs doesn't have the langId AND
153+
// the langId isn't set as disabled...
154+
if (!customSingleLineLangs.has(langId) && !this.isLangIdDisabled(langId)) {
150155
disposables.push(this.setLanguageConfiguration(langId, true));
151156
}
152157
}
@@ -495,8 +500,10 @@ export class Configuration {
495500
if (config.comments.blockComment.includes("/*")) {
496501
// console.log(langId, config.comments);
497502

498-
// If Language ID isn't already in the langArray...
499-
if (!langArray.includes(langId)) {
503+
// If Language ID isn't already in the langArray AND
504+
// the langId isn't set as disabled...
505+
if (!langArray.includes(langId) && !this.isLangIdDisabled(langId)) {
506+
// Add it to the array.
500507
langArray.push(langId);
501508
}
502509
}
@@ -513,9 +520,10 @@ export class Configuration {
513520
langArray = [];
514521
for (let langId of multiLineStyleBlocksLangs) {
515522
// If langId is exists (ie. not NULL or empty string) AND
516-
// the array doesn't already include langId,
517-
// then add it to the array.
518-
if (langId && !langArray.includes(langId)) {
523+
// the array doesn't already include langId, AND
524+
// the langId isn't set as disabled...
525+
if (langId && !langArray.includes(langId) && !this.isLangIdDisabled(langId)) {
526+
// Add it to the array.
519527
langArray.push(langId);
520528
}
521529
}
@@ -558,9 +566,10 @@ export class Configuration {
558566
style = ";";
559567
}
560568

561-
// If style any empty string, (i.e. not an unsupported single-line
562-
// comment like bat's @rem)...
563-
if (style != "") {
569+
// If style is NOT an empty string, (i.e. not an unsupported single-line
570+
// comment like bat's @rem), AND
571+
// the langId isn't set as disabled...
572+
if (style != "" && !this.isLangIdDisabled(langId)) {
564573
// Set the langId and it's style into the Map.
565574
tempMap.set(langId, style);
566575
}
@@ -577,6 +586,9 @@ export class Configuration {
577586
// Get user-customized langIds for the //-style and add to the map.
578587
let customSlashLangs = this.getConfigurationValue<string[]>("slashStyleBlocks");
579588
for (let langId of customSlashLangs) {
589+
// If langId is exists (ie. not NULL or empty string) AND
590+
// the langId is longer than 0, AND
591+
// the langId isn't set as disabled...
580592
if (langId && langId.length > 0) {
581593
tempMap.set(langId, "//");
582594
}
@@ -585,15 +597,21 @@ export class Configuration {
585597
// Get user-customized langIds for the #-style and add to the map.
586598
let customHashLangs = this.getConfigurationValue<string[]>("hashStyleBlocks");
587599
for (let langId of customHashLangs) {
588-
if (langId && langId.length > 0) {
600+
// If langId is exists (ie. not NULL or empty string) AND
601+
// the langId is longer than 0, AND
602+
// the langId isn't set as disabled...
603+
if (langId && langId.length > 0 && !this.isLangIdDisabled(langId)) {
589604
tempMap.set(langId, "#");
590605
}
591606
}
592607

593608
// Get user-customized langIds for the ;-style and add to the map.
594609
let customSemicolonLangs = this.getConfigurationValue<string[]>("semicolonStyleBlocks");
595610
for (let langId of customSemicolonLangs) {
596-
if (langId && langId.length > 0) {
611+
// If langId is exists (ie. not NULL or empty string) AND
612+
// the langId is longer than 0, AND
613+
// the langId isn't set as disabled...
614+
if (langId && langId.length > 0 && !this.isLangIdDisabled(langId)) {
597615
tempMap.set(langId, ";");
598616
}
599617
}

0 commit comments

Comments
 (0)