File tree Expand file tree Collapse file tree
packages/opencode/src/tool Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,8 +142,8 @@ export const EditTool = Tool.define("edit", {
142142 const diagnostics = await LSP . diagnostics ( )
143143 const normalizedFilePath = Filesystem . normalizePath ( filePath )
144144 const issues = diagnostics [ normalizedFilePath ] ?? [ ]
145- if ( issues . length > 0 ) {
146- const errors = issues . filter ( ( item ) => item . severity === 1 )
145+ const errors = issues . filter ( ( item ) => item . severity === 1 )
146+ if ( errors . length > 0 ) {
147147 const limited = errors . slice ( 0 , MAX_DIAGNOSTICS_PER_FILE )
148148 const suffix =
149149 errors . length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${ errors . length - MAX_DIAGNOSTICS_PER_FILE } more` : ""
Original file line number Diff line number Diff line change @@ -83,11 +83,11 @@ export const WriteTool = Tool.define("write", {
8383 const normalizedFilepath = Filesystem . normalizePath ( filepath )
8484 let projectDiagnosticsCount = 0
8585 for ( const [ file , issues ] of Object . entries ( diagnostics ) ) {
86- if ( issues . length === 0 ) continue
87- const sorted = issues . toSorted ( ( a , b ) => ( a . severity ?? 4 ) - ( b . severity ?? 4 ) )
88- const limited = sorted . slice ( 0 , MAX_DIAGNOSTICS_PER_FILE )
86+ const errors = issues . filter ( ( item ) => item . severity === 1 )
87+ if ( errors . length === 0 ) continue
88+ const limited = errors . slice ( 0 , MAX_DIAGNOSTICS_PER_FILE )
8989 const suffix =
90- issues . length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${ issues . length - MAX_DIAGNOSTICS_PER_FILE } more` : ""
90+ errors . length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${ errors . length - MAX_DIAGNOSTICS_PER_FILE } more` : ""
9191 if ( file === normalizedFilepath ) {
9292 output += `\nThis file has errors, please fix\n<file_diagnostics>\n${ limited . map ( LSP . Diagnostic . pretty ) . join ( "\n" ) } ${ suffix } \n</file_diagnostics>\n`
9393 continue
You can’t perform that action at this time.
0 commit comments