File tree 3 files changed +14
-3
lines changed
src/vs/workbench/contrib/positronPlots/browser
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,12 @@ export const DynamicPlotInstance = (props: DynamicPlotInstanceProps) => {
51
51
const ratio = DOM . getActiveWindow ( ) . devicePixelRatio ;
52
52
const disposables = new DisposableStore ( ) ;
53
53
54
+ // The frontend shoudn't send invalid sizes so be defensive. Sometimes the
55
+ // plot container is in a strange state when it's hidden.
56
+ if ( props . height <= 0 || props . width <= 0 ) {
57
+ return ;
58
+ }
59
+
54
60
// If the plot is already rendered, use the old image until the new one is ready.
55
61
if ( props . plotClient . lastRender ) {
56
62
setUri ( props . plotClient . lastRender . uri ) ;
Original file line number Diff line number Diff line change @@ -63,8 +63,8 @@ export const PlotsContainer = (props: PlotContainerProps) => {
63
63
64
64
const historyPx = props . showHistory ? HistoryPx : 0 ;
65
65
const historyEdge = historyBottom ? 'history-bottom' : 'history-right' ;
66
- const plotHeight = historyBottom ? props . height - historyPx : props . height ;
67
- const plotWidth = historyBottom ? props . width : props . width - historyPx ;
66
+ const plotHeight = historyBottom && props . height > 0 ? props . height - historyPx : props . height ;
67
+ const plotWidth = historyBottom || props . width <= 0 ? props . width : props . width - historyPx ;
68
68
69
69
useEffect ( ( ) => {
70
70
// Ensure the selected plot is visible. We do this so that the history
@@ -87,6 +87,11 @@ export const PlotsContainer = (props: PlotContainerProps) => {
87
87
} , [ plotHistoryRef ] ) ;
88
88
89
89
useEffect ( ( ) => {
90
+ // Be defensive against null sizes when pane is invisible
91
+ if ( plotWidth <= 0 || plotHeight <= 0 ) {
92
+ return ;
93
+ }
94
+
90
95
// Propagate current render settings. Use a debouncer to avoid excessive
91
96
// messaging to language kernels.
92
97
const debounceTimer = setTimeout ( ( ) => {
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ export const PositronPlots = (props: PropsWithChildren<PositronPlotsProps>) => {
135
135
< ActionBars { ...props } zoomHandler = { zoomHandler } zoomLevel = { zoom } />
136
136
< PlotsContainer
137
137
darkFilterMode = { darkFilterMode }
138
- height = { height - 34 }
138
+ height = { height > 0 ? height - 34 : 0 }
139
139
positronPlotsService = { props . positronPlotsService }
140
140
showHistory = { showHistory }
141
141
visible = { visible }
You can’t perform that action at this time.
0 commit comments