Allow comments in multiline RC file commands. Fixes issue #4555

Signed-off-by: Tushar <tusharbarman123@gmail.com>
This commit is contained in:
Tushar 2023-04-02 11:22:40 +05:30
parent 2b6a27c678
commit e1b0b7da75

View file

@ -59,17 +59,21 @@ export async function runRc(rc: string) {
}
export function rcFileToExCmds(rcText: string): string[] {
// string-join lines that end with /
const joined = rcText.replace(/\\\n/g, "")
// Split into individual excmds
const excmds = joined.split("\n")
const excmds = rcText.split("\n")
// Remove empty and comment lines
return excmds.filter(
const ex= excmds.filter(
x =>
/\S/.test(x) &&
!x.trim().startsWith('"') &&
!x.trim().startsWith("#"),
)
const res= ex.join("\n")
// string-join lines that end with /
const joined = res.replace(/\\\n/g, "")
return joined.split("\n")
}