Skip to content

Commit f918d52

Browse files
committed
don't presist little size changes
1 parent f37df00 commit f918d52

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/vs/editor/contrib/suggest/suggestWidget.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ export class SuggestWidget implements IDisposable {
153153
this._persistedSize = new PersistedWidgetSize(_storageService, editor);
154154

155155
let persistedSize: dom.Dimension | undefined;
156+
let currentSize: dom.Dimension | undefined;
156157
let persistHeight = false;
157158
let persistWidth = false;
158159
this._disposables.add(this.element.onDidWillResize(() => {
159160
this._contentWidget.lockPreference();
160161
persistedSize = this._persistedSize.restore();
162+
currentSize = this.element.size;
161163
}));
162164
this._disposables.add(this.element.onDidResize(e => {
163165

@@ -166,14 +168,15 @@ export class SuggestWidget implements IDisposable {
166168
persistHeight = persistHeight || !!e.north || !!e.south;
167169
persistWidth = persistWidth || !!e.east || !!e.west;
168170
if (e.done) {
169-
170-
// 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 / 3);
171174
let { width, height } = this.element.size;
172-
if (persistedSize) {
173-
if (!persistHeight) {
175+
if (persistedSize && currentSize) {
176+
if (!persistHeight || Math.abs(currentSize.height - height) > threshold) {
174177
height = persistedSize.height;
175178
}
176-
if (!persistWidth) {
179+
if (!persistWidth || Math.abs(currentSize.width - width) > threshold) {
177180
width = persistedSize.width;
178181
}
179182
}
@@ -182,6 +185,7 @@ export class SuggestWidget implements IDisposable {
182185
// reset working state
183186
this._contentWidget.unlockPreference();
184187
persistedSize = undefined;
188+
currentSize = undefined;
185189
persistHeight = false;
186190
persistWidth = false;
187191
}

0 commit comments

Comments
 (0)