Skip to content

Commit

Permalink
Fix quoting issues of ArrayProcessor (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalre committed Apr 30, 2023
1 parent 150429b commit b89e97b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/processor/array-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { GenericProcessor } from "./generic-processor"

export class ArrayProcessor extends GenericProcessor {
constructor(text: string) {
super("array", /\[([^[]*)\]/g, text)
super("array", /(?<=:\s+)\[([^[]*)\]/g, text)
}
}
2 changes: 1 addition & 1 deletion src/processor/block-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { GenericProcessor } from "./generic-processor"

export class BlockProcessor extends GenericProcessor {
constructor(text: string) {
super("block", /(?!<)(?<=:\s)([|>])((?!:).|[\r\n])+/g, text)
super("block", /(?!<)(?<=:\s+)([|>])((?!:).|[\r\n])+/g, text)
}
}
13 changes: 13 additions & 0 deletions src/test/suite/processor/array-processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,17 @@ suite("Test ArrayProcessor - preprocess()", () => {
equal(arrayprocessor.store.size, 1)
equal(arrayprocessor.store.get("vscode-yaml-sort.array.0"), "[ \"CMD\", \"pg_isready\", \"-q\", \"-d\", \"DB_NAME\", \"-U\", \"DB_USER\" ]")
})

test("GitHub issue #129: False remove trailing quotes by Array Processor.", () => {
const textExamples = [ "section: '*[a]'", "section: *[a]", "section: '[a]'", "section: [a]"]

textExamples.forEach(text => {
const arrayprocessor = new ArrayProcessor(text)

arrayprocessor.preprocess()
arrayprocessor.postprocess()

equal(arrayprocessor.text, text)
})
})
})
2 changes: 1 addition & 1 deletion src/test/suite/processor/block-processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ suite("Test BlockProcessor - preprocess()", () => {
blockprocessor.preprocess()

equal(blockprocessor.store.size, 0)
})
})
})

0 comments on commit b89e97b

Please sign in to comment.