@@ -25,6 +25,7 @@ import { DarkFilter, IPositronPlotClient, IPositronPlotsService, PlotRenderForma
25
25
import { StaticPlotClient } from '../../../../services/positronPlots/common/staticPlotClient.js' ;
26
26
import { PlotSizingPolicyIntrinsic } from '../../../../services/positronPlots/common/sizingPolicyIntrinsic.js' ;
27
27
import { PlotSizingPolicyAuto } from '../../../../services/positronPlots/common/sizingPolicyAuto.js' ;
28
+ import { DisposableStore } from '../../../../../base/common/lifecycle.js' ;
28
29
29
30
/**
30
31
* PlotContainerProps interface.
@@ -94,27 +95,37 @@ export const PlotsContainer = (props: PlotContainerProps) => {
94
95
return ;
95
96
}
96
97
97
- let policy = props . positronPlotsService . selectedSizingPolicy ;
98
+ const notify = ( ) => {
99
+ let policy = props . positronPlotsService . selectedSizingPolicy ;
98
100
99
- if ( policy instanceof PlotSizingPolicyIntrinsic ) {
100
- policy = new PlotSizingPolicyAuto ;
101
- }
101
+ if ( policy instanceof PlotSizingPolicyIntrinsic ) {
102
+ policy = new PlotSizingPolicyAuto ;
103
+ }
102
104
103
- const viewPortSize = {
104
- height : plotHeight ,
105
- width : plotWidth ,
106
- }
107
- let size = policy . getPlotSize ( viewPortSize ) ;
108
- size = size ? size : viewPortSize ;
105
+ const viewPortSize = {
106
+ height : plotHeight ,
107
+ width : plotWidth ,
108
+ }
109
+ let size = policy . getPlotSize ( viewPortSize ) ;
110
+ size = size ? size : viewPortSize ;
109
111
110
- // Propagate current render settings. Use a debouncer to avoid excessive
111
- // messaging to language kernels.
112
- const debounceTimer = setTimeout ( ( ) => {
113
112
props . positronPlotsService . setPlotsRenderSettings ( {
114
113
size,
115
114
pixel_ratio : DOM . getActiveWindow ( ) . devicePixelRatio ,
116
115
format : PlotRenderFormat . Png , // Currently hard-coded
117
116
} ) ;
117
+ } ;
118
+
119
+ // Renotify if the sizing policy changes
120
+ const disposables = new DisposableStore ( ) ;
121
+ disposables . add ( props . positronPlotsService . onDidChangeSizingPolicy ( ( _policy ) => {
122
+ notify ( ) ;
123
+ } ) ) ;
124
+
125
+ // Propagate current render settings. Use a debouncer to avoid excessive
126
+ // messaging to language kernels.
127
+ const debounceTimer = setTimeout ( ( ) => {
128
+ notify ( )
118
129
} , 500 ) ;
119
130
120
131
return ( ) => clearTimeout ( debounceTimer ) ;
0 commit comments