fix(config-manager): skip string literals when counting braces in JSONC provider replacement
This commit is contained in:
parent
554926209d
commit
c4572a25fb
@ -61,9 +61,25 @@ export function addProviderConfig(config: InstallConfig): ConfigMergeResult {
|
|||||||
} else {
|
} else {
|
||||||
let depth = 0
|
let depth = 0
|
||||||
let braceEnd = braceStart
|
let braceEnd = braceStart
|
||||||
|
let inString = false
|
||||||
|
let escape = false
|
||||||
for (let i = braceStart; i < content.length; i++) {
|
for (let i = braceStart; i < content.length; i++) {
|
||||||
if (content[i] === "{") depth++
|
const ch = content[i]
|
||||||
else if (content[i] === "}") {
|
if (escape) {
|
||||||
|
escape = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (ch === "\\") {
|
||||||
|
escape = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (ch === '"') {
|
||||||
|
inString = !inString
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (inString) continue
|
||||||
|
if (ch === "{") depth++
|
||||||
|
else if (ch === "}") {
|
||||||
depth--
|
depth--
|
||||||
if (depth === 0) {
|
if (depth === 0) {
|
||||||
braceEnd = i
|
braceEnd = i
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user