File tree Expand file tree Collapse file tree
packages/opencode/src/lsp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,20 +188,26 @@ export namespace LSPClient {
188188 )
189189 log . info ( "waiting for diagnostics" , { path : normalizedPath } )
190190 let unsub : ( ) => void
191+ let debounceTimer : ReturnType < typeof setTimeout > | undefined
191192 return await withTimeout (
192193 new Promise < void > ( ( resolve ) => {
193194 unsub = Bus . subscribe ( Event . Diagnostics , ( event ) => {
194195 if ( event . properties . path === normalizedPath && event . properties . serverID === result . serverID ) {
195- log . info ( "got diagnostics" , { path : normalizedPath } )
196- unsub ?.( )
197- resolve ( )
196+ // Debounce to allow LSP to send follow-up diagnostics (e.g., semantic after syntax)
197+ if ( debounceTimer ) clearTimeout ( debounceTimer )
198+ debounceTimer = setTimeout ( ( ) => {
199+ log . info ( "got diagnostics" , { path : normalizedPath } )
200+ unsub ?.( )
201+ resolve ( )
202+ } , 150 )
198203 }
199204 } )
200205 } ) ,
201206 3000 ,
202207 )
203208 . catch ( ( ) => { } )
204209 . finally ( ( ) => {
210+ if ( debounceTimer ) clearTimeout ( debounceTimer )
205211 unsub ?.( )
206212 } )
207213 } ,
You can’t perform that action at this time.
0 commit comments