@@ -7,6 +7,7 @@ import { formatResponse } from "../../core/prompts/responses"
77import { DecorationController } from "./DecorationController"
88import * as diff from "diff"
99import { diagnosticsToProblemsString , getNewDiagnostics } from "../diagnostics"
10+ import delay from "delay"
1011
1112export const DIFF_VIEW_URI_SCHEME = "cline-diff"
1213
@@ -157,6 +158,35 @@ export class DiffViewProvider {
157158 await vscode . window . showTextDocument ( vscode . Uri . file ( absolutePath ) , { preview : false } )
158159 await this . closeAllDiffViews ( )
159160
161+ try {
162+ // Wait for Rust Analyzer to catch up before fetching post-diagnostics
163+ const rustAnalyzer = vscode . extensions . getExtension ( "rust-lang.rust-analyzer" )
164+ if ( rustAnalyzer ?. isActive && ( absolutePath . endsWith ( ".rs" ) || absolutePath . endsWith ( ".toml" ) ) ) {
165+ const startTime = Date . now ( )
166+ const INITIAL_DELAY = 1000 // 1 second
167+ const TIMEOUT = 30000 // 30 seconds
168+
169+ // Give rust-analyzer some time to detect changes
170+ while ( rustAnalyzer . exports ?. lastStatus ?. quiescent === true ) {
171+ if ( Date . now ( ) - startTime > INITIAL_DELAY ) {
172+ break
173+ }
174+ await delay ( 50 )
175+ }
176+
177+ while ( rustAnalyzer . exports ?. lastStatus ?. quiescent === false ) {
178+ if ( Date . now ( ) - startTime > TIMEOUT ) {
179+ console . error ( "Timeout waiting for rust-analyzer to become quiescent" )
180+ console . dir ( rustAnalyzer . exports ?. lastStatus )
181+ break
182+ }
183+ await delay ( 100 )
184+ }
185+ }
186+ } catch ( err ) {
187+ // We don't mind if rust-analyzer isn't installed
188+ }
189+
160190 /*
161191 Getting diagnostics before and after the file edit is a better approach than
162192 automatically tracking problems in real-time. This method ensures we only
0 commit comments