@@ -10,7 +10,7 @@ import { EditorAction2 } from 'vs/editor/browser/editorExtensions';
10
10
import { EmbeddedCodeEditorWidget , EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget' ;
11
11
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
12
12
import { InteractiveEditorController , InteractiveEditorRunOptions } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController' ;
13
- import { CTX_INTERACTIVE_EDITOR_FOCUSED , CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST , CTX_INTERACTIVE_EDITOR_HAS_PROVIDER , CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST , CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST , CTX_INTERACTIVE_EDITOR_EMPTY , CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION , CTX_INTERACTIVE_EDITOR_VISIBLE , MENU_INTERACTIVE_EDITOR_WIDGET , MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD , MENU_INTERACTIVE_EDITOR_WIDGET_STATUS , CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK , CTX_INTERACTIVE_EDITOR_SHOWING_DIFF , CTX_INTERACTIVE_EDITOR_EDIT_MODE , EditMode , CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE , MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE , CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE , CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED , CTX_INTERACTIVE_EDITOR_DID_EDIT } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
13
+ import { CTX_INTERACTIVE_EDITOR_FOCUSED , CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST , CTX_INTERACTIVE_EDITOR_HAS_PROVIDER , CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST , CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST , CTX_INTERACTIVE_EDITOR_EMPTY , CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION , CTX_INTERACTIVE_EDITOR_VISIBLE , MENU_INTERACTIVE_EDITOR_WIDGET , MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD , MENU_INTERACTIVE_EDITOR_WIDGET_STATUS , CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK , CTX_INTERACTIVE_EDITOR_SHOWING_DIFF , CTX_INTERACTIVE_EDITOR_EDIT_MODE , EditMode , CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE , MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE , CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE , CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED , CTX_INTERACTIVE_EDITOR_DID_EDIT , CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
14
14
import { localize } from 'vs/nls' ;
15
15
import { IAction2Options , MenuRegistry } from 'vs/platform/actions/common/actions' ;
16
16
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService' ;
@@ -66,6 +66,34 @@ export class StartSessionAction extends EditorAction2 {
66
66
}
67
67
}
68
68
69
+ export class UnstashSessionAction extends EditorAction2 {
70
+ constructor ( ) {
71
+ super ( {
72
+ id : 'interactiveEditor.unstash' ,
73
+ title : { value : localize ( 'unstash' , 'Resume Last Dismissed Code Chat' ) , original : 'Resume Last Dismissed Code Chat' } ,
74
+ category : AbstractInteractiveEditorAction . category ,
75
+ precondition : ContextKeyExpr . and ( CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION , EditorContextKeys . writable ) ,
76
+ keybinding : {
77
+ weight : KeybindingWeight . WorkbenchContrib ,
78
+ primary : KeyMod . CtrlCmd | KeyCode . KeyZ ,
79
+ }
80
+ } ) ;
81
+ }
82
+
83
+ override runEditorCommand ( _accessor : ServicesAccessor , editor : ICodeEditor , ..._args : any [ ] ) {
84
+ const ctrl = InteractiveEditorController . get ( editor ) ;
85
+ if ( ctrl ) {
86
+ const session = ctrl . unstashLastSession ( ) ;
87
+ if ( session ) {
88
+ ctrl . run ( {
89
+ existingSession : session ,
90
+ isUnstashed : true
91
+ } ) ;
92
+ }
93
+ }
94
+ }
95
+ }
96
+
69
97
abstract class AbstractInteractiveEditorAction extends EditorAction2 {
70
98
71
99
static readonly category = { value : localize ( 'cat' , 'Interactive Editor' ) , original : 'Interactive Editor' } ;
@@ -263,7 +291,7 @@ MenuRegistry.appendMenuItem(MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, {
263
291
} ) ;
264
292
265
293
266
- export class DicardAction extends AbstractInteractiveEditorAction {
294
+ export class DiscardAction extends AbstractInteractiveEditorAction {
267
295
268
296
constructor ( ) {
269
297
super ( {
@@ -273,7 +301,7 @@ export class DicardAction extends AbstractInteractiveEditorAction {
273
301
precondition : CTX_INTERACTIVE_EDITOR_VISIBLE ,
274
302
keybinding : {
275
303
weight : KeybindingWeight . EditorContrib ,
276
- primary : KeyMod . CtrlCmd + KeyCode . Escape
304
+ primary : KeyCode . Escape
277
305
} ,
278
306
menu : {
279
307
id : MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD ,
@@ -417,14 +445,9 @@ export class ApplyPreviewEdits extends AbstractInteractiveEditorAction {
417
445
keybinding : [ {
418
446
weight : KeybindingWeight . EditorContrib + 10 ,
419
447
primary : KeyMod . CtrlCmd | KeyCode . Enter ,
420
- } , {
421
- weight : KeybindingWeight . EditorContrib + 10 ,
422
- primary : KeyCode . Escape ,
423
- when : CTX_INTERACTIVE_EDITOR_EDIT_MODE . notEqualsTo ( EditMode . Preview )
424
448
} ] ,
425
449
menu : {
426
450
id : MENU_INTERACTIVE_EDITOR_WIDGET_STATUS ,
427
- when : CTX_INTERACTIVE_EDITOR_EDIT_MODE . isEqualTo ( EditMode . Preview ) ,
428
451
group : '0_main' ,
429
452
order : 0
430
453
}
0 commit comments