From 2807185355d15351b5215ce40404838092058ae6 Mon Sep 17 00:00:00 2001 From: shenghui kevin Date: Sat, 21 Feb 2026 04:18:31 -0800 Subject: [PATCH] fix: skip {file:} substitution only when no active lines contain the 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 #14478 --- packages/opencode/src/config/config.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index aad0fd76c4be..217663c16369 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -1265,10 +1265,8 @@ export namespace Config { const lines = text.split("\n") for (const match of fileMatches) { - const lineIndex = lines.findIndex((line) => line.includes(match)) - if (lineIndex !== -1 && lines[lineIndex].trim().startsWith("//")) { - continue - } + const lineIndex = lines.findIndex((line) => line.includes(match) && !line.trim().startsWith("//")) + if (lineIndex === -1) continue let filePath = match.replace(/^\{file:/, "").replace(/\}$/, "") if (filePath.startsWith("~/")) { filePath = path.join(os.homedir(), filePath.slice(2))