@@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
1212import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
1313import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
1414import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget' ;
15- import { CTX_INTERACTIVE_EDITOR_FOCUSED , 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_STATUS , MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE , CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE , IInteractiveEditorSlashCommand } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
15+ import { CTX_INTERACTIVE_EDITOR_FOCUSED , 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_STATUS , MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE , CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE , IInteractiveEditorSlashCommand , MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK , ACTION_ACCEPT_CHANGES } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
1616import { IModelDeltaDecoration , ITextModel } from 'vs/editor/common/model' ;
1717import { Dimension , addDisposableListener , getTotalHeight , getTotalWidth , h , reset } from 'vs/base/browser/dom' ;
1818import { Emitter , Event , MicrotaskEmitter } from 'vs/base/common/event' ;
@@ -28,7 +28,7 @@ import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
2828import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController' ;
2929import { IPosition , Position } from 'vs/editor/common/core/position' ;
3030import { DEFAULT_FONT_FAMILY } from 'vs/workbench/browser/style' ;
31- import { DropdownWithDefaultActionViewItem , createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
31+ import { DropdownWithDefaultActionViewItem , IMenuEntryActionViewItemOptions , MenuEntryActionViewItem , createActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
3232import { CompletionItem , CompletionItemInsertTextRule , CompletionItemKind , CompletionItemProvider , CompletionList , ProviderResult , TextEdit } from 'vs/editor/common/languages' ;
3333import { EditOperation , ISingleEditOperation } from 'vs/editor/common/core/editOperation' ;
3434import { ILanguageSelection , ILanguageService } from 'vs/editor/common/languages/language' ;
@@ -44,10 +44,12 @@ import { invertLineRange, lineRangeAsRange } from 'vs/workbench/contrib/interact
4444import { ICodeEditorViewState , ScrollType } from 'vs/editor/common/editorCommon' ;
4545import { LineRange } from 'vs/editor/common/core/lineRange' ;
4646import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
47- import { SubmenuItemAction } from 'vs/platform/actions/common/actions' ;
47+ import { MenuItemAction , SubmenuItemAction } from 'vs/platform/actions/common/actions' ;
4848import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
4949import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
5050import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution' ;
51+ import { assertType } from 'vs/base/common/types' ;
52+ import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels' ;
5153
5254const defaultAriaLabel = localize ( 'aria-label' , "Interactive Editor Input" ) ;
5355
@@ -136,8 +138,10 @@ export class InteractiveEditorWidget {
136138 h ( 'div.previewCreateTitle.show-file-icons@previewCreateTitle' ) ,
137139 h ( 'div.previewCreate.hidden@previewCreate' ) ,
138140 h ( 'div.status@status' , [
141+ h ( 'div.label.info.hidden@infoLabel' ) ,
139142 h ( 'div.actions.hidden@statusToolbar' ) ,
140- h ( 'div.label.hidden@statusLabel' )
143+ h ( 'div.label.status.hidden@statusLabel' ) ,
144+ h ( 'div.actions.hidden@feedbackToolbar' ) ,
141145 ] ) ,
142146 h ( 'div.markdownMessage.hidden@markdownMessage' , [
143147 h ( 'div.message@message' ) ,
@@ -286,13 +290,42 @@ export class InteractiveEditorWidget {
286290 return this . _instantiationService . createInstance ( DropdownWithDefaultActionViewItem , action , { ...options , renderKeybindingWithDefaultActionLabel : true , persistLastActionId : false } ) ;
287291 }
288292
293+ if ( action . id === ACTION_ACCEPT_CHANGES ) {
294+ const ButtonLikeActionViewItem = class extends MenuEntryActionViewItem {
295+
296+ override render ( container : HTMLElement ) : void {
297+ this . options . icon = false ;
298+ super . render ( container ) ;
299+ assertType ( this . element ) ;
300+ this . element . classList . add ( 'button-item' ) ;
301+ }
302+
303+ protected override updateLabel ( ) : void {
304+ assertType ( this . label ) ;
305+ assertType ( this . action instanceof MenuItemAction ) ;
306+ const label = MenuItemAction . label ( this . action . item , { renderShortTitle : true } ) ;
307+ const labelElements = renderLabelWithIcons ( `$(check)${ label } ` ) ;
308+ reset ( this . label , ...labelElements ) ;
309+ }
310+
311+ protected override updateClass ( ) : void {
312+ // noop
313+ }
314+ } ;
315+ return this . _instantiationService . createInstance ( ButtonLikeActionViewItem , < MenuItemAction > action , < IMenuEntryActionViewItemOptions > options ) ;
316+ }
317+
289318 return createActionViewItem ( this . _instantiationService , action , options ) ;
290319 }
291320 } ;
292321 const statusToolbar = this . _instantiationService . createInstance ( MenuWorkbenchToolBar , this . _elements . statusToolbar , MENU_INTERACTIVE_EDITOR_WIDGET_STATUS , { ...workbenchToolbarOptions , hiddenItemStrategy : HiddenItemStrategy . Ignore } ) ;
293322 this . _store . add ( statusToolbar . onDidChangeMenuItems ( ( ) => this . _onDidChangeHeight . fire ( ) ) ) ;
294323 this . _store . add ( statusToolbar ) ;
295324
325+ const feedbackToolbar = this . _instantiationService . createInstance ( MenuWorkbenchToolBar , this . _elements . feedbackToolbar , MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK , { ...workbenchToolbarOptions , hiddenItemStrategy : HiddenItemStrategy . Ignore } ) ;
326+ this . _store . add ( feedbackToolbar . onDidChangeMenuItems ( ( ) => this . _onDidChangeHeight . fire ( ) ) ) ;
327+ this . _store . add ( feedbackToolbar ) ;
328+
296329 // preview editors
297330 this . _previewDiffEditor = this . _store . add ( _instantiationService . createInstance ( EmbeddedDiffEditorWidget , this . _elements . previewDiff , _previewEditorEditorOptions , { modifiedEditor : codeEditorWidgetOptions , originalEditor : codeEditorWidgetOptions } , parentEditor ) ) ;
298331
@@ -389,6 +422,8 @@ export class InteractiveEditorWidget {
389422
390423 updateToolbar ( show : boolean ) {
391424 this . _elements . statusToolbar . classList . toggle ( 'hidden' , ! show ) ;
425+ this . _elements . feedbackToolbar . classList . toggle ( 'hidden' , ! show ) ;
426+ this . _elements . status . classList . toggle ( 'actions' , show ) ;
392427 this . _onDidChangeHeight . fire ( ) ;
393428 }
394429
@@ -409,6 +444,12 @@ export class InteractiveEditorWidget {
409444 this . _onDidChangeHeight . fire ( ) ;
410445 }
411446
447+ updateInfo ( message : string ) : void {
448+ this . _elements . infoLabel . classList . toggle ( 'hidden' , ! message ) ;
449+ this . _elements . infoLabel . innerText = message ;
450+ this . _onDidChangeHeight . fire ( ) ;
451+ }
452+
412453 updateStatus ( message : string , ops : { classes ?: string [ ] ; resetAfter ?: number ; keepMessage ?: boolean } = { } ) {
413454 const isTempMessage = typeof ops . resetAfter === 'number' ;
414455 if ( isTempMessage && ! this . _elements . statusLabel . dataset [ 'state' ] ) {
@@ -419,7 +460,7 @@ export class InteractiveEditorWidget {
419460 } , ops . resetAfter ) ;
420461 }
421462 reset ( this . _elements . statusLabel , message ) ;
422- this . _elements . statusLabel . className = `label ${ ( ops . classes ?? [ ] ) . join ( ' ' ) } ` ;
463+ this . _elements . statusLabel . className = `label status ${ ( ops . classes ?? [ ] ) . join ( ' ' ) } ` ;
423464 this . _elements . statusLabel . classList . toggle ( 'hidden' , ! message ) ;
424465 if ( isTempMessage ) {
425466 this . _elements . statusLabel . dataset [ 'state' ] = 'temp' ;
@@ -437,6 +478,7 @@ export class InteractiveEditorWidget {
437478 reset ( this . _elements . statusLabel ) ;
438479 this . _elements . statusLabel . classList . toggle ( 'hidden' , true ) ;
439480 this . _elements . statusToolbar . classList . add ( 'hidden' ) ;
481+ this . _elements . feedbackToolbar . classList . add ( 'hidden' ) ;
440482 this . hideCreatePreview ( ) ;
441483 this . hideEditsPreview ( ) ;
442484 this . _onDidChangeHeight . fire ( ) ;
0 commit comments