@@ -23,7 +23,7 @@ registerAction2(class CopyCellOutputAction extends Action2 {
2323 constructor ( ) {
2424 super ( {
2525 id : COPY_OUTPUT_COMMAND_ID ,
26- title : localize ( 'notebookActions.copyOutput' , "Copy Output" ) ,
26+ title : localize ( 'notebookActions.copyOutput' , "Copy Cell Output" ) ,
2727 menu : {
2828 id : MenuId . NotebookOutputToolbar ,
2929 when : NOTEBOOK_CELL_HAS_OUTPUTS
@@ -42,7 +42,14 @@ registerAction2(class CopyCellOutputAction extends Action2 {
4242 }
4343
4444 let outputViewModel : ICellOutputViewModel | undefined ;
45- if ( ! outputContext ) {
45+ if ( outputContext && 'outputId' in outputContext && typeof outputContext . outputId === 'string' ) {
46+ outputViewModel = getOutputViewModelFromId ( outputContext . outputId , notebookEditor ) ;
47+ } else if ( outputContext && 'outputViewModel' in outputContext ) {
48+ outputViewModel = outputContext . outputViewModel ;
49+ }
50+
51+ if ( ! outputViewModel ) {
52+ // not able to find the output from the provided context, use the active cell
4653 const activeCell = notebookEditor . getActiveCell ( ) ;
4754 if ( ! activeCell ) {
4855 return ;
@@ -55,10 +62,6 @@ registerAction2(class CopyCellOutputAction extends Action2 {
5562 } else {
5663 outputViewModel = activeCell . outputsViewModels . find ( output => output . pickedMimeType ?. isTrusted ) ;
5764 }
58- } else if ( 'outputId' in outputContext && typeof outputContext . outputId === 'string' ) {
59- outputViewModel = getOutputViewModelFromId ( outputContext . outputId , notebookEditor ) ;
60- } else {
61- outputViewModel = outputContext . outputViewModel ;
6265 }
6366
6467 if ( ! outputViewModel ) {
0 commit comments