6
6
import { renderMarkdown } from 'vs/base/browser/markdownRenderer' ;
7
7
import { Barrier , raceCancellationError } from 'vs/base/common/async' ;
8
8
import { CancellationTokenSource } from 'vs/base/common/cancellation' ;
9
+ import { toErrorMessage } from 'vs/base/common/errorMessage' ;
9
10
import { Emitter , Event } from 'vs/base/common/event' ;
10
11
import { DisposableStore , toDisposable } from 'vs/base/common/lifecycle' ;
11
12
import { isEqual } from 'vs/base/common/resources' ;
@@ -24,6 +25,7 @@ import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions
24
25
import { localize } from 'vs/nls' ;
25
26
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
26
27
import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
28
+ import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
27
29
import { IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
28
30
import { ILogService } from 'vs/platform/log/common/log' ;
29
31
import { EditResponse , EmptyResponse , ErrorResponse , IInteractiveEditorSessionService , MarkdownResponse , Session , SessionExchange } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession' ;
@@ -101,6 +103,7 @@ export class InteractiveEditorController implements IEditorContribution {
101
103
@IConfigurationService private readonly _configurationService : IConfigurationService ,
102
104
@IModelService private readonly _modelService : IModelService ,
103
105
@INotebookEditorService private readonly _notebookEditorService : INotebookEditorService ,
106
+ @IDialogService private readonly _dialogService : IDialogService ,
104
107
@IContextKeyService contextKeyService : IContextKeyService ,
105
108
) {
106
109
this . _ctxHasActiveRequest = CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST . bindTo ( contextKeyService ) ;
@@ -612,7 +615,13 @@ export class InteractiveEditorController implements IEditorContribution {
612
615
if ( this . _strategy ) {
613
616
const strategy = this . _strategy ;
614
617
this . _strategy = undefined ;
615
- await strategy ?. apply ( ) ;
618
+ try {
619
+ await strategy ?. apply ( ) ;
620
+ } catch ( err ) {
621
+ this . _dialogService . error ( localize ( 'err.apply' , "Failed to apply changes." , toErrorMessage ( err ) ) ) ;
622
+ this . _logService . error ( '[IE] FAILED to apply changes' ) ;
623
+ this . _logService . error ( err ) ;
624
+ }
616
625
strategy ?. dispose ( ) ;
617
626
this . _messages . fire ( Message . END_SESSION ) ;
618
627
@@ -626,7 +635,13 @@ export class InteractiveEditorController implements IEditorContribution {
626
635
if ( this . _strategy ) {
627
636
const strategy = this . _strategy ;
628
637
this . _strategy = undefined ;
629
- await strategy ?. cancel ( ) ;
638
+ try {
639
+ await strategy ?. cancel ( ) ;
640
+ } catch ( err ) {
641
+ this . _dialogService . error ( localize ( 'err.discard' , "Failed to discard changes." , toErrorMessage ( err ) ) ) ;
642
+ this . _logService . error ( '[IE] FAILED to discard changes' ) ;
643
+ this . _logService . error ( err ) ;
644
+ }
630
645
strategy ?. dispose ( ) ;
631
646
this . _messages . fire ( Message . END_SESSION ) ;
632
647
}
0 commit comments