@@ -84,6 +84,10 @@ class PersistedWidgetSize {
84
84
store ( size : dom . Dimension ) {
85
85
this . _service . store ( this . _key , JSON . stringify ( size ) , StorageScope . GLOBAL ) ;
86
86
}
87
+
88
+ reset ( ) : void {
89
+ this . _service . remove ( this . _key , StorageScope . GLOBAL ) ;
90
+ }
87
91
}
88
92
89
93
export class SuggestWidget implements IDisposable {
@@ -149,11 +153,13 @@ export class SuggestWidget implements IDisposable {
149
153
this . _persistedSize = new PersistedWidgetSize ( _storageService , editor ) ;
150
154
151
155
let persistedSize : dom . Dimension | undefined ;
156
+ let currentSize : dom . Dimension | undefined ;
152
157
let persistHeight = false ;
153
158
let persistWidth = false ;
154
159
this . _disposables . add ( this . element . onDidWillResize ( ( ) => {
155
160
this . _contentWidget . lockPreference ( ) ;
156
161
persistedSize = this . _persistedSize . restore ( ) ;
162
+ currentSize = this . element . size ;
157
163
} ) ) ;
158
164
this . _disposables . add ( this . element . onDidResize ( e => {
159
165
@@ -162,14 +168,15 @@ export class SuggestWidget implements IDisposable {
162
168
persistHeight = persistHeight || ! ! e . north || ! ! e . south ;
163
169
persistWidth = persistWidth || ! ! e . east || ! ! e . west ;
164
170
if ( e . done ) {
165
-
166
- // only store width or height value that have changed
171
+ // only store width or height value that have changed and also
172
+ // only store changes that are above a certain threshold
173
+ const threshold = Math . floor ( this . getLayoutInfo ( ) . itemHeight / 2 ) ;
167
174
let { width, height } = this . element . size ;
168
- if ( persistedSize ) {
169
- if ( ! persistHeight ) {
175
+ if ( persistedSize && currentSize ) {
176
+ if ( ! persistHeight || Math . abs ( currentSize . height - height ) <= threshold ) {
170
177
height = persistedSize . height ;
171
178
}
172
- if ( ! persistWidth ) {
179
+ if ( ! persistWidth || Math . abs ( currentSize . width - width ) <= threshold ) {
173
180
width = persistedSize . width ;
174
181
}
175
182
}
@@ -178,6 +185,7 @@ export class SuggestWidget implements IDisposable {
178
185
// reset working state
179
186
this . _contentWidget . unlockPreference ( ) ;
180
187
persistedSize = undefined ;
188
+ currentSize = undefined ;
181
189
persistHeight = false ;
182
190
persistWidth = false ;
183
191
}
@@ -683,6 +691,10 @@ export class SuggestWidget implements IDisposable {
683
691
}
684
692
}
685
693
694
+ resetPersistedSize ( ) : void {
695
+ this . _persistedSize . reset ( ) ;
696
+ }
697
+
686
698
hideWidget ( ) : void {
687
699
this . loadingTimeout . dispose ( ) ;
688
700
this . _setState ( State . Hidden ) ;
0 commit comments