Skip to content

Comments

fix(config): skip {file:} substitution only when no active lines match#14545

Open
kevinWangSheng wants to merge 1 commit intoanomalyco:devfrom
kevinWangSheng:fix/config-file-substitution-comment
Open

fix(config): skip {file:} substitution only when no active lines match#14545
kevinWangSheng wants to merge 1 commit intoanomalyco:devfrom
kevinWangSheng:fix/config-file-substitution-comment

Conversation

@kevinWangSheng
Copy link

Issue for this PR

Closes #14478

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

load() in config.ts uses lines.findIndex() to locate {file:...} tokens for substitution. If the first line containing the token is a comment, continue skips substitution for that token entirely — even when the same token appears on a later non-comment line.

Moved the comment check into the findIndex predicate so it finds the first non-comment line with the token. If no non-comment line contains it, the token is correctly skipped.

Before:

const lineIndex = lines.findIndex((line) => line.includes(match))
if (lineIndex !== -1 && lines[lineIndex].trim().startsWith("//")) {
  continue
}

After:

const lineIndex = lines.findIndex((line) => line.includes(match) && !line.trim().startsWith("//"))
if (lineIndex === -1) continue

How did you verify your code works?

Tested with a jsonc config containing both a commented and active {file:...} token pointing to the same path. Before the fix the token stayed literal; after, it resolves correctly.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…token

findIndex returns the first line containing the token, which may be a
comment. When it is, substitution is skipped entirely even if the same
token appears on a later active line. Fix by filtering out commented
lines in the findIndex predicate so we only skip tokens that truly
have no non-comment occurrences.

Fixes anomalyco#14478
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config {file:...} substitution skipped when same token appears in commented line

1 participant