Explorar el Código

fix: grep omitting text after a colon (#1053)

Jeremy Mack hace 7 meses
padre
commit
5d67e13df5
Se han modificado 1 ficheros con 4 adiciones y 5 borrados
  1. 4 5
      packages/opencode/src/tool/grep.ts

+ 4 - 5
packages/opencode/src/tool/grep.ts

@@ -55,12 +55,11 @@ export const GrepTool = Tool.define({
     for (const line of lines) {
       if (!line) continue
 
-      const parts = line.split(":", 3)
-      if (parts.length < 3) continue
+      const [filePath, lineNumStr, ...lineTextParts] = line.split(":")
+      if (!filePath || !lineNumStr || lineTextParts.length === 0) continue
 
-      const filePath = parts[0]
-      const lineNum = parseInt(parts[1], 10)
-      const lineText = parts[2]
+      const lineNum = parseInt(lineNumStr, 10)
+      const lineText = lineTextParts.join(":")
 
       const file = Bun.file(filePath)
       const stats = await file.stat().catch(() => null)