@@ -372,14 +372,16 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
372372
373373 this . update_providers_context_state ( )
374374
375- vscode . window . onDidChangeWindowState ( async ( e ) => {
376- if ( e . focused ) {
377- this . send_message ( {
378- command : 'RESET_APPLY_BUTTON_TEMPORARY_DISABLED_STATE'
379- } )
380- handle_get_tasks ( this )
381- }
382- } )
375+ this . extension_context . subscriptions . push (
376+ vscode . window . onDidChangeWindowState ( async ( e ) => {
377+ if ( e . focused ) {
378+ this . send_message ( {
379+ command : 'RESET_APPLY_BUTTON_TEMPORARY_DISABLED_STATE'
380+ } )
381+ handle_get_tasks ( this )
382+ }
383+ } )
384+ )
383385
384386 this . extension_context . subscriptions . push (
385387 vscode . workspace . onDidChangeWorkspaceFolders ( ( ) => {
@@ -487,38 +489,43 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
487489 this . send_currently_open_file_text ( )
488490 }
489491
490- vscode . window . onDidChangeActiveTextEditor ( ( ) =>
491- setTimeout ( update_editor_state , 100 )
492+ this . extension_context . subscriptions . push (
493+ vscode . window . onDidChangeActiveTextEditor ( ( ) =>
494+ setTimeout ( update_editor_state , 100 )
495+ )
492496 )
493497 update_editor_state ( )
494498
495- vscode . window . onDidChangeTextEditorSelection ( ( event ) => {
496- const selection = event . textEditor . selection
497- let new_selection : SelectionState | null = null
498-
499- if ( ! selection . isEmpty ) {
500- new_selection = {
501- text : event . textEditor . document . getText ( selection ) ,
502- start_line : selection . start . line + 1 ,
503- start_col : selection . start . character + 1 ,
504- end_line : selection . end . line + 1 ,
505- end_col : selection . end . character + 1
499+ this . extension_context . subscriptions . push (
500+ vscode . window . onDidChangeTextEditorSelection ( ( event ) => {
501+ const selection = event . textEditor . selection
502+ let new_selection : SelectionState | null = null
503+
504+ if ( ! selection . isEmpty ) {
505+ new_selection = {
506+ text : event . textEditor . document . getText ( selection ) ,
507+ start_line : selection . start . line + 1 ,
508+ start_col : selection . start . character + 1 ,
509+ end_line : selection . end . line + 1 ,
510+ end_col : selection . end . character + 1
511+ }
506512 }
507- }
508513
509- const has_changed =
510- ( this . current_selection ?. text ?? null ) !== ( new_selection ?. text ?? null )
514+ const has_changed =
515+ ( this . current_selection ?. text ?? null ) !==
516+ ( new_selection ?. text ?? null )
511517
512- if ( has_changed ) {
513- this . current_selection = new_selection
514- if ( this . webview_view ) {
515- this . send_message ( {
516- command : 'EDITOR_SELECTION_CHANGED' ,
517- current_selection : new_selection
518- } )
518+ if ( has_changed ) {
519+ this . current_selection = new_selection
520+ if ( this . webview_view ) {
521+ this . send_message ( {
522+ command : 'EDITOR_SELECTION_CHANGED' ,
523+ current_selection : new_selection
524+ } )
525+ }
519526 }
520- }
521- } )
527+ } )
528+ )
522529
523530 const update_selection_state = ( ) => {
524531 const active_text_editor = vscode . window . activeTextEditor
@@ -544,19 +551,23 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
544551 }
545552 }
546553
547- vscode . window . onDidChangeActiveTextEditor ( ( ) =>
548- setTimeout ( update_selection_state , 100 )
554+ this . extension_context . subscriptions . push (
555+ vscode . window . onDidChangeActiveTextEditor ( ( ) =>
556+ setTimeout ( update_selection_state , 100 )
557+ )
549558 )
550559 update_selection_state ( )
551560
552- vscode . workspace . onDidChangeTextDocument ( ( event ) => {
553- if (
554- vscode . window . activeTextEditor &&
555- event . document === vscode . window . activeTextEditor . document
556- ) {
557- this . send_currently_open_file_text ( )
558- }
559- } )
561+ this . extension_context . subscriptions . push (
562+ vscode . workspace . onDidChangeTextDocument ( ( event ) => {
563+ if (
564+ vscode . window . activeTextEditor &&
565+ event . document === vscode . window . activeTextEditor . document
566+ ) {
567+ this . send_currently_open_file_text ( )
568+ }
569+ } )
570+ )
560571 }
561572
562573 public cancel_all_intelligent_updates ( ) {
0 commit comments