@@ -11,7 +11,7 @@ import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/commo
1111import { InputFocusedContext , InputFocusedContextKey } from 'vs/platform/contextkey/common/contextkeys' ;
1212import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
1313import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
14- import { DELETE_CELL_COMMAND_ID , EDIT_CELL_COMMAND_ID , INSERT_CODE_CELL_ABOVE_COMMAND_ID , INSERT_CODE_CELL_BELOW_COMMAND_ID , INSERT_MARKDOWN_CELL_ABOVE_COMMAND_ID , INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID , MOVE_CELL_DOWN_COMMAND_ID , MOVE_CELL_UP_COMMAND_ID , SAVE_CELL_COMMAND_ID } from 'vs/workbench/contrib/notebook/browser/constants' ;
14+ import { DELETE_CELL_COMMAND_ID , EDIT_CELL_COMMAND_ID , INSERT_CODE_CELL_ABOVE_COMMAND_ID , INSERT_CODE_CELL_BELOW_COMMAND_ID , INSERT_MARKDOWN_CELL_ABOVE_COMMAND_ID , INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID , MOVE_CELL_DOWN_COMMAND_ID , MOVE_CELL_UP_COMMAND_ID , SAVE_CELL_COMMAND_ID , COPY_CELL_UP_COMMAND_ID , COPY_CELL_DOWN_COMMAND_ID } from 'vs/workbench/contrib/notebook/browser/constants' ;
1515import { INotebookEditor , KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED , NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
1616import { INotebookService } from 'vs/workbench/contrib/notebook/browser/notebookService' ;
1717import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel' ;
@@ -438,14 +438,13 @@ export class InsertCodeCellAboveAction extends MenuItemAction {
438438 super (
439439 {
440440 id : INSERT_CODE_CELL_ABOVE_COMMAND_ID ,
441- title : localize ( 'notebookActions.insertCodeCellAbove' , "Insert Code Cell Above" )
441+ title : localize ( 'notebookActions.insertCodeCellAbove' , "Insert Code Cell Above" ) ,
442+ icon : { id : 'codicon/add' }
442443 } ,
443444 undefined ,
444445 { shouldForwardArgs : true } ,
445446 contextKeyService ,
446447 commandService ) ;
447-
448- this . class = 'codicon-add' ;
449448 }
450449}
451450
@@ -457,14 +456,17 @@ export class InsertCodeCellBelowAction extends MenuItemAction {
457456 super (
458457 {
459458 id : INSERT_CODE_CELL_BELOW_COMMAND_ID ,
460- title : localize ( 'notebookActions.insertCodeCellBelow' , "Insert Code Cell Below" )
459+ title : localize ( 'notebookActions.insertCodeCellBelow' , "Insert Code Cell Below" ) ,
460+ icon : { id : 'codicon/add' }
461+ } ,
462+ {
463+ id : INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID ,
464+ title : localize ( 'notebookActions.insertMarkdownCellBelow' , "Insert Markdown Cell Below" ) ,
465+ icon : { id : 'codicon/add' }
461466 } ,
462- undefined ,
463467 { shouldForwardArgs : true } ,
464468 contextKeyService ,
465469 commandService ) ;
466-
467- this . class = 'codicon-add' ;
468470 }
469471}
470472
@@ -476,14 +478,13 @@ export class InsertMarkdownCellAboveAction extends MenuItemAction {
476478 super (
477479 {
478480 id : INSERT_MARKDOWN_CELL_ABOVE_COMMAND_ID ,
479- title : localize ( 'notebookActions.insertMarkdownCellAbove' , "Insert Markdown Cell Above" )
481+ title : localize ( 'notebookActions.insertMarkdownCellAbove' , "Insert Markdown Cell Above" ) ,
482+ icon : { id : 'codicon/add' }
480483 } ,
481484 undefined ,
482485 { shouldForwardArgs : true } ,
483486 contextKeyService ,
484487 commandService ) ;
485-
486- this . class = 'codicon-add' ;
487488 }
488489}
489490
@@ -495,14 +496,13 @@ export class InsertMarkdownCellBelowAction extends MenuItemAction {
495496 super (
496497 {
497498 id : INSERT_MARKDOWN_CELL_BELOW_COMMAND_ID ,
498- title : localize ( 'notebookActions.insertMarkdownCellBelow' , "Insert Markdown Cell Below" )
499+ title : localize ( 'notebookActions.insertMarkdownCellBelow' , "Insert Markdown Cell Below" ) ,
500+ icon : { id : 'codicon/add' }
499501 } ,
500502 undefined ,
501503 { shouldForwardArgs : true } ,
502504 contextKeyService ,
503505 commandService ) ;
504-
505- this . class = 'codicon-add' ;
506506 }
507507}
508508
@@ -540,14 +540,13 @@ export class EditCellAction extends MenuItemAction {
540540 super (
541541 {
542542 id : EDIT_CELL_COMMAND_ID ,
543- title : localize ( 'notebookActions.editCell' , "Edit Cell" )
543+ title : localize ( 'notebookActions.editCell' , "Edit Cell" ) ,
544+ icon : { id : 'codicon/pencil' }
544545 } ,
545546 undefined ,
546547 { shouldForwardArgs : true } ,
547548 contextKeyService ,
548549 commandService ) ;
549-
550- this . class = 'codicon-pencil' ;
551550 }
552551}
553552
@@ -580,14 +579,13 @@ export class SaveCellAction extends MenuItemAction {
580579 super (
581580 {
582581 id : SAVE_CELL_COMMAND_ID ,
583- title : localize ( 'notebookActions.saveCell' , "Save Cell" )
582+ title : localize ( 'notebookActions.saveCell' , "Save Cell" ) ,
583+ icon : { id : 'codicon/save' }
584584 } ,
585585 undefined ,
586586 { shouldForwardArgs : true } ,
587587 contextKeyService ,
588588 commandService ) ;
589-
590- this . class = 'codicon-save' ;
591589 }
592590}
593591
@@ -620,14 +618,15 @@ export class DeleteCellAction extends MenuItemAction {
620618 super (
621619 {
622620 id : DELETE_CELL_COMMAND_ID ,
623- title : localize ( 'notebookActions.deleteCell' , "Delete Cell" )
621+ title : localize ( 'notebookActions.deleteCell' , "Delete Cell" ) ,
622+ icon : { id : 'codicon/x' }
624623 } ,
625624 undefined ,
626625 { shouldForwardArgs : true } ,
627626 contextKeyService ,
628627 commandService ) ;
629628
630- this . class = 'codicon-trash ' ;
629+ this . class = 'codicon-x ' ;
631630 }
632631}
633632
@@ -637,6 +636,12 @@ async function moveCell(context: INotebookCellActionContext, direction: 'up' | '
637636 context . notebookEditor . moveCellDown ( context . cell ) ;
638637}
639638
639+ async function copyCell ( context : INotebookCellActionContext , direction : 'up' | 'down' ) : Promise < void > {
640+ const text = context . cell . getText ( ) ;
641+ const newCellDirection = direction === 'up' ? 'above' : 'below' ;
642+ return context . notebookEditor . insertNotebookCell ( context . cell , context . cell . cellKind , newCellDirection , text ) ;
643+ }
644+
640645registerAction2 ( class extends Action2 {
641646 constructor ( ) {
642647 super (
@@ -666,14 +671,17 @@ export class MoveCellUpAction extends MenuItemAction {
666671 super (
667672 {
668673 id : MOVE_CELL_UP_COMMAND_ID ,
669- title : localize ( 'notebookActions.moveCellUp' , "Move Cell Up" )
674+ title : localize ( 'notebookActions.moveCellUp' , "Move Cell Up" ) ,
675+ icon : { id : 'codicon/arrow-up' }
676+ } ,
677+ {
678+ id : COPY_CELL_UP_COMMAND_ID ,
679+ title : localize ( 'notebookActions.copyCellUp' , "Copy Cell Up" ) ,
680+ icon : { id : 'codicon/arrow-up' }
670681 } ,
671- undefined ,
672682 { shouldForwardArgs : true } ,
673683 contextKeyService ,
674684 commandService ) ;
675-
676- this . class = 'codicon-arrow-up' ;
677685 }
678686}
679687
@@ -706,13 +714,60 @@ export class MoveCellDownAction extends MenuItemAction {
706714 super (
707715 {
708716 id : MOVE_CELL_DOWN_COMMAND_ID ,
709- title : localize ( 'notebookActions.moveCellDown' , "Move Cell Down" )
717+ title : localize ( 'notebookActions.moveCellDown' , "Move Cell Down" ) ,
718+ icon : { id : 'codicon/arrow-down' }
719+ } ,
720+ {
721+ id : COPY_CELL_DOWN_COMMAND_ID ,
722+ title : localize ( 'notebookActions.copyCellDown' , "Copy Cell Down" ) ,
723+ icon : { id : 'codicon/arrow-down' }
710724 } ,
711- undefined ,
712725 { shouldForwardArgs : true } ,
713726 contextKeyService ,
714727 commandService ) ;
715728
716729 this . class = 'codicon-arrow-down' ;
717730 }
718731}
732+
733+ registerAction2 ( class extends Action2 {
734+ constructor ( ) {
735+ super (
736+ {
737+ id : COPY_CELL_UP_COMMAND_ID ,
738+ title : localize ( 'notebookActions.copyCellUp' , "Copy Cell Up" )
739+ } ) ;
740+ }
741+
742+ async run ( accessor : ServicesAccessor , context ?: INotebookCellActionContext ) {
743+ if ( ! context ) {
744+ context = getActiveCellContext ( accessor ) ;
745+ if ( ! context ) {
746+ return ;
747+ }
748+ }
749+
750+ return copyCell ( context , 'up' ) ;
751+ }
752+ } ) ;
753+
754+ registerAction2 ( class extends Action2 {
755+ constructor ( ) {
756+ super (
757+ {
758+ id : COPY_CELL_DOWN_COMMAND_ID ,
759+ title : localize ( 'notebookActions.copyCellDown' , "Copy Cell Down" )
760+ } ) ;
761+ }
762+
763+ async run ( accessor : ServicesAccessor , context ?: INotebookCellActionContext ) {
764+ if ( ! context ) {
765+ context = getActiveCellContext ( accessor ) ;
766+ if ( ! context ) {
767+ return ;
768+ }
769+ }
770+
771+ return copyCell ( context , 'down' ) ;
772+ }
773+ } ) ;
0 commit comments