@@ -163,7 +163,14 @@ export const activate = (context: vscode.ExtensionContext) => {
163163 ignore_active_editor_change = false ;
164164 return ;
165165 }
166- send_update ( false ) ;
166+ // Skip an update if we've already sent a `CurrentFile` for this editor.
167+ if (
168+ current_editor ===
169+ vscode . window . activeTextEditor
170+ ) {
171+ return ;
172+ }
173+ send_update ( true ) ;
167174 } ) ,
168175 ) ;
169176
@@ -174,6 +181,9 @@ export const activate = (context: vscode.ExtensionContext) => {
174181 ignore_selection_change = false ;
175182 return ;
176183 }
184+ console_log (
185+ "CodeChat Editor extension: sending updated cursor/scroll position." ,
186+ ) ;
177187 send_update ( false ) ;
178188 } ,
179189 ) ,
@@ -246,19 +256,6 @@ export const activate = (context: vscode.ExtensionContext) => {
246256 webview_panel = undefined ;
247257 await stop_client ( ) ;
248258 } ) ;
249-
250- // Render when the webview panel is shown.
251- webview_panel . onDidChangeViewState (
252- (
253- _event : vscode . WebviewPanelOnDidChangeViewStateEvent ,
254- ) => {
255- // Only render if the webview was activated;
256- // this event also occurs when it's deactivated.
257- if ( webview_panel ?. active ) {
258- send_update ( true ) ;
259- }
260- } ,
261- ) ;
262259 }
263260 }
264261
@@ -367,6 +364,9 @@ export const activate = (context: vscode.ExtensionContext) => {
367364 await sendResult ( id , "OutOfSync" ) ;
368365 // Send an `Update` with the full text to
369366 // re-sync the Client.
367+ console_log (
368+ "CodeChat Editor extension: sending update because Client is out of sync." ,
369+ ) ;
370370 send_update ( true ) ;
371371 break ;
372372 }
@@ -395,10 +395,10 @@ export const activate = (context: vscode.ExtensionContext) => {
395395 }
396396 }
397397 }
398- vscode . workspace . applyEdit ( wse ) . then ( ( ) => {
399- ignore_text_document_change = false ;
400- ignore_selection_change = false ;
401- } ) ;
398+ await vscode . workspace . applyEdit ( wse ) ;
399+ ignore_text_document_change = false ;
400+ ignore_selection_change = false ;
401+
402402 // Now that we've updated our text, update the
403403 // associated version as well.
404404 version = current_update . contents . version ;
@@ -425,7 +425,6 @@ export const activate = (context: vscode.ExtensionContext) => {
425425 // viewport, but a bit below it.
426426 TextEditorRevealType . AtTop ,
427427 ) ;
428- ignore_selection_change = false ;
429428 }
430429
431430 let cursor_line = current_update . cursor_position ;
@@ -443,7 +442,6 @@ export const activate = (context: vscode.ExtensionContext) => {
443442 cursor_position ,
444443 ) ,
445444 ] ;
446- ignore_selection_change = false ;
447445 }
448446 await sendResult ( id ) ;
449447 break ;
0 commit comments