@@ -172,8 +172,13 @@ export async function activate(): Promise<void> {
172172 getCustomConfigProviders ( ) . forEach ( provider => void client . onRegisterCustomConfigurationProvider ( provider ) ) ;
173173 } ) ;
174174
175- disposables . push ( vscode . workspace . onDidChangeConfiguration ( onDidChangeSettings ) ) ;
175+ // These handlers for didChangeTextDocument and didOpenTextDocument are intentionally synchronous and are
176+ // intended primarily to maintain openFileVersions with the most recent versions of files, as quickly as
177+ // possible, without being delayed by awaits or queued behind other LSP messages, etc..
176178 disposables . push ( vscode . workspace . onDidChangeTextDocument ( onDidChangeTextDocument ) ) ;
179+ disposables . push ( vscode . workspace . onDidOpenTextDocument ( onDidOpenTextDocument ) ) ;
180+
181+ disposables . push ( vscode . workspace . onDidChangeConfiguration ( onDidChangeSettings ) ) ;
177182 disposables . push ( vscode . window . onDidChangeTextEditorVisibleRanges ( ( e ) => clients . ActiveClient . enqueue ( async ( ) => onDidChangeTextEditorVisibleRanges ( e ) ) ) ) ;
178183 disposables . push ( vscode . window . onDidChangeActiveTextEditor ( ( e ) => clients . ActiveClient . enqueue ( async ( ) => onDidChangeActiveTextEditor ( e ) ) ) ) ;
179184 ui . didChangeActiveEditor ( ) ; // Handle already active documents (for non-cpp files that we don't register didOpen).
@@ -303,6 +308,11 @@ function onDidChangeTextDocument(event: vscode.TextDocumentChangeEvent): void {
303308 me . onDidChangeTextDocument ( event ) ;
304309}
305310
311+ function onDidOpenTextDocument ( document : vscode . TextDocument ) : void {
312+ const me : Client = clients . getClientFor ( document . uri ) ;
313+ me . onDidOpenTextDocument ( document ) ;
314+ }
315+
306316let noActiveEditorTimeout : NodeJS . Timeout | undefined ;
307317
308318async function onDidChangeTextEditorVisibleRanges ( event : vscode . TextEditorVisibleRangesChangeEvent ) : Promise < void > {
0 commit comments