@@ -20,6 +20,7 @@ import { IPositronPlotClient, IPositronPlotsService, isZoomablePlotClient, ZoomL
20
20
import { PlotClientInstance } from '../../../services/languageRuntime/common/languageRuntimePlotClient.js' ;
21
21
import { ThemeIcon } from '../../../../base/common/themables.js' ;
22
22
import { Uri } from 'vscode' ;
23
+ import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js' ;
23
24
24
25
export enum PlotActionTarget {
25
26
VIEW = 'view' ,
@@ -627,29 +628,10 @@ export class PlotsSizingPolicyAction extends AbstractPlotsAction {
627
628
}
628
629
}
629
630
630
- export class PlotsActiveEditorZoomAction extends Action2 {
631
- static readonly ID = 'workbench.action.positronPlots.zoomActiveEditor' ;
631
+ export abstract class PlotsEditorZoomAction extends Action2 {
632
632
static readonly SUBMENU_ID = MenuId . for ( 'positronPlots.zoomSubmenu' ) ;
633
+ static readonly ZOOM_LEVEL_CONTEXT_KEY = 'positronPlotsEditorZoomLevel' ;
633
634
634
- constructor ( ) {
635
- super ( {
636
- id : PlotsActiveEditorZoomAction . ID ,
637
- title : localize2 ( 'positronPlots.zoomSubMenuTitle' , 'Zoom' ) , // Title for the action if shown in lists like Keyboard Shortcuts
638
- category, // POSITRON_PLOTS_ACTION_CATEGORY
639
- f1 : false , // Not in command palette by default
640
- // The 'menu' and 'icon' properties are removed.
641
- // This action itself is not directly placed in a menu to act as a submenu trigger.
642
- // An ISubmenuItem will be registered in positronPlots.contribution.ts for that.
643
- } ) ;
644
- }
645
-
646
- async run ( accessor : ServicesAccessor ) : Promise < void > {
647
- // This is a no-op. The action primarily serves to define SUBMENU_ID.
648
- // The actual zoom functionality is handled by individual zoom actions.
649
- }
650
- }
651
-
652
- abstract class PlotsEditorZoomAction extends Action2 {
653
635
abstract zoomLevel : ZoomLevel ;
654
636
655
637
constructor ( descriptor : IAction2Options ) {
@@ -682,9 +664,12 @@ export class ZoomToFitAction extends PlotsEditorZoomAction {
682
664
category,
683
665
f1 : false , // Not in command palette by default
684
666
precondition : PLOT_IS_ACTIVE_EDITOR ,
667
+ toggled : {
668
+ condition : ContextKeyExpr . equals ( 'positronPlotsEditorZoomLevel' , ZoomLevel . Fit . toString ( ) ) ,
669
+ } ,
685
670
menu : [
686
671
{
687
- id : PlotsActiveEditorZoomAction . SUBMENU_ID ,
672
+ id : PlotsEditorZoomAction . SUBMENU_ID ,
688
673
when : PLOT_IS_ACTIVE_EDITOR ,
689
674
group : 'navigation' ,
690
675
order : 1 ,
@@ -705,9 +690,12 @@ export class ZoomFiftyAction extends PlotsEditorZoomAction {
705
690
category,
706
691
f1 : false , // Not in command palette by default
707
692
precondition : PLOT_IS_ACTIVE_EDITOR ,
693
+ toggled : {
694
+ condition : ContextKeyExpr . equals ( 'positronPlotsEditorZoomLevel' , ZoomLevel . Fifty . toString ( ) ) ,
695
+ } ,
708
696
menu : [
709
697
{
710
- id : PlotsActiveEditorZoomAction . SUBMENU_ID ,
698
+ id : PlotsEditorZoomAction . SUBMENU_ID ,
711
699
when : PLOT_IS_ACTIVE_EDITOR ,
712
700
group : 'navigation' ,
713
701
order : 2 ,
@@ -728,9 +716,12 @@ export class ZoomSeventyFiveAction extends PlotsEditorZoomAction {
728
716
category,
729
717
f1 : false , // Not in command palette by default
730
718
precondition : PLOT_IS_ACTIVE_EDITOR ,
719
+ toggled : {
720
+ condition : ContextKeyExpr . equals ( 'positronPlotsEditorZoomLevel' , ZoomLevel . SeventyFive . toString ( ) ) ,
721
+ } ,
731
722
menu : [
732
723
{
733
- id : PlotsActiveEditorZoomAction . SUBMENU_ID ,
724
+ id : PlotsEditorZoomAction . SUBMENU_ID ,
734
725
when : PLOT_IS_ACTIVE_EDITOR ,
735
726
group : 'navigation' ,
736
727
order : 3 ,
@@ -751,9 +742,12 @@ export class ZoomOneHundredAction extends PlotsEditorZoomAction {
751
742
category,
752
743
f1 : false , // Not in command palette by default
753
744
precondition : PLOT_IS_ACTIVE_EDITOR ,
745
+ toggled : {
746
+ condition : ContextKeyExpr . equals ( 'positronPlotsEditorZoomLevel' , ZoomLevel . OneHundred . toString ( ) ) ,
747
+ } ,
754
748
menu : [
755
749
{
756
- id : PlotsActiveEditorZoomAction . SUBMENU_ID ,
750
+ id : PlotsEditorZoomAction . SUBMENU_ID ,
757
751
when : PLOT_IS_ACTIVE_EDITOR ,
758
752
group : 'navigation' ,
759
753
order : 4 ,
@@ -774,9 +768,12 @@ export class ZoomTwoHundredAction extends PlotsEditorZoomAction {
774
768
category,
775
769
f1 : false , // Not in command palette by default
776
770
precondition : PLOT_IS_ACTIVE_EDITOR ,
771
+ toggled : {
772
+ condition : ContextKeyExpr . equals ( 'positronPlotsEditorZoomLevel' , ZoomLevel . TwoHundred . toString ( ) ) ,
773
+ } ,
777
774
menu : [
778
775
{
779
- id : PlotsActiveEditorZoomAction . SUBMENU_ID ,
776
+ id : PlotsEditorZoomAction . SUBMENU_ID ,
780
777
when : PLOT_IS_ACTIVE_EDITOR ,
781
778
group : 'navigation' ,
782
779
order : 5 ,
0 commit comments