Skip to content

Commit 51f2525

Browse files
committed
Fix processing of .editorConfig files with booleans.
1 parent fcd0b0c commit 51f2525

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Extension/src/LanguageServer/editorConfig.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ function parseEditorConfigContent(content: string): Record<string, any> {
9292
const [key, ...values] = line.split('=');
9393
if (key && values.length > 0) {
9494
const trimmedKey = key.trim();
95-
const value = values.join('=').trim();
95+
let value: any = values.join('=').trim();
9696
if (currentSection) {
9797
// Ensure the current section is initialized.
9898
if (!config[currentSection]) {
9999
config[currentSection] = {};
100100
}
101+
// Convert 'true' and 'false' to boolean.
102+
if (value === 'true') {
103+
value = true;
104+
} else if (value === 'false') {
105+
value = false;
106+
}
101107
config[currentSection][trimmedKey] = value;
102108
}
103109
}
@@ -114,7 +120,7 @@ function getEditorConfig(filePath: string): any {
114120
const rootDir: string = path.parse(currentDir).root;
115121

116122
// Traverse from the file's directory to the root directory.
117-
for (;;) {
123+
for (; ;) {
118124
const editorConfigPath: string = path.join(currentDir, '.editorconfig');
119125
if (fs.existsSync(editorConfigPath)) {
120126
const configFileContent: string = fs.readFileSync(editorConfigPath, 'utf-8');
@@ -139,7 +145,7 @@ function getEditorConfig(filePath: string): any {
139145
});
140146

141147
// Check if the current .editorconfig is the root.
142-
if (configData['*']?.root?.toLowerCase() === 'true') {
148+
if (configData['*']?.root === true) {
143149
break; // Stop searching after processing the root = true file.
144150
}
145151
}

0 commit comments

Comments
 (0)