Skip to content

Commit f5ac258

Browse files
committed
log/telemetry for completion durations, #29126
1 parent 50f78a6 commit f5ac258

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class SuggestDetailsWidget {
4242
private readonly _markdownRenderer: MarkdownRenderer;
4343
private _renderDisposeable?: IDisposable;
4444
private _borderWidth: number = 1;
45-
private _size = new dom.Dimension(330, 50);
45+
private _size = new dom.Dimension(330, 0);
4646

4747
constructor(
4848
private readonly _editor: ICodeEditor,
@@ -101,15 +101,19 @@ export class SuggestDetailsWidget {
101101
this._close.style.width = lineHeightPx;
102102
}
103103

104-
private _lineHeight(): number {
105-
return this._editor.getOption(EditorOption.suggestLineHeight) || this._editor.getOption(EditorOption.fontInfo).lineHeight;
104+
getLayoutInfo() {
105+
const lineHeight = this._editor.getOption(EditorOption.suggestLineHeight) || this._editor.getOption(EditorOption.fontInfo).lineHeight;
106+
const borderWidth = this._borderWidth;
107+
const borderHeight = borderWidth * 2;
108+
return { lineHeight, borderWidth, borderHeight };
106109
}
107110

111+
108112
renderLoading(): void {
109113
this._type.textContent = nls.localize('loading', "Loading...");
110114
this._docs.textContent = '';
111115
this.domNode.classList.remove('no-docs');
112-
this.layout(this.size.width, this._lineHeight() * 2);
116+
this.layout(this.size.width, this.getLayoutInfo().lineHeight * 2);
113117
this._onDidChangeContents.fire(this);
114118
}
115119

@@ -174,7 +178,7 @@ export class SuggestDetailsWidget {
174178
};
175179

176180
this._body.scrollTop = 0;
177-
this.layout(this._size.width, this._lineHeight() * (2 + (documentation ? 5 : 0)));
181+
this.layout(this._size.width, this.getLayoutInfo().lineHeight * (2 + (documentation ? 5 : 0)));
178182
this._onDidChangeContents.fire(this);
179183
}
180184

@@ -295,27 +299,28 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
295299

296300
_placeAtAnchor(anchorBox: dom.IDomNodePagePosition, size: dom.Dimension) {
297301
const bodyBox = dom.getClientArea(document.body);
298-
const borderHeight = 2 * this.widget.borderWidth;
302+
303+
const { borderWidth, borderHeight, lineHeight } = this.widget.getLayoutInfo();
299304

300305
let maxSizeTop: dom.Dimension;
301306
let maxSizeBottom: dom.Dimension;
302-
let minSize = new dom.Dimension(220, this._editor.getOption(EditorOption.suggestLineHeight) || this._editor.getOption(EditorOption.fontInfo).lineHeight);
307+
let minSize = new dom.Dimension(220, 2 * lineHeight);
303308

304309
let left = 0;
305310
let top = anchorBox.top;
306311
let bottom = anchorBox.top + anchorBox.height - borderHeight;
307312

308313
// position: EAST, west, south
309314
let width = bodyBox.width - (anchorBox.left + anchorBox.width);
310-
left = -this.widget.borderWidth + anchorBox.left + anchorBox.width;
315+
left = -borderWidth + anchorBox.left + anchorBox.width;
311316
maxSizeTop = new dom.Dimension(bodyBox.width - (anchorBox.left + anchorBox.width), bodyBox.height - anchorBox.top);
312317
maxSizeBottom = maxSizeTop.with(undefined, anchorBox.top + anchorBox.height);
313318

314319
// position: east, WEST, south
315320
if (anchorBox.left > width) {
316321
// pos = SuggestDetailsPosition.West;
317322
width = anchorBox.left;
318-
left = Math.max(0, anchorBox.left - (size.width + this.widget.borderWidth));
323+
left = Math.max(0, anchorBox.left - (size.width + borderWidth));
319324
maxSizeTop = new dom.Dimension(anchorBox.left, bodyBox.height - anchorBox.top);
320325
maxSizeBottom = maxSizeTop.with(undefined, maxSizeBottom.height);
321326
}
@@ -324,7 +329,7 @@ export class SuggestDetailsOverlay implements IOverlayWidget {
324329
if (anchorBox.width > width * 1.3 && bodyBox.height - (anchorBox.top + anchorBox.height) > anchorBox.height) {
325330
width = anchorBox.width;
326331
left = anchorBox.left;
327-
top = -this.widget.borderWidth + anchorBox.top + anchorBox.height;
332+
top = -borderWidth + anchorBox.top + anchorBox.height;
328333
maxSizeTop = new dom.Dimension(anchorBox.width - borderHeight, bodyBox.height - (anchorBox.top + anchorBox.height));
329334
maxSizeBottom = maxSizeTop.with(undefined, anchorBox.top);
330335
minSize = minSize.with(maxSizeTop.width);

0 commit comments

Comments
 (0)