Skip to content

Commit e73419b

Browse files
authored
rename suggestions: fix width overflow for long suggestions (microsoft#206212)
* rename suggestions: fix width overflow * rename suggestions: increase approximate font width * rename suggestions: use editor#typicalHalfwidthCharacterWidth
1 parent 48087fe commit e73419b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/vs/editor/contrib/rename/browser/renameInputField.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ class CandidatesView {
435435
private _lineHeight: number;
436436
private _availableHeight: number;
437437
private _minimumWidth: number;
438+
private _typicalHalfwidthCharacterWidth: number;
438439

439440
private _disposables: DisposableStore;
440441

@@ -446,6 +447,7 @@ class CandidatesView {
446447
this._minimumWidth = 0;
447448

448449
this._lineHeight = opts.fontInfo.lineHeight;
450+
this._typicalHalfwidthCharacterWidth = opts.fontInfo.typicalHalfwidthCharacterWidth;
449451

450452
this._listContainer = document.createElement('div');
451453
this._listContainer.style.fontFamily = opts.fontInfo.fontFamily;
@@ -515,7 +517,6 @@ class CandidatesView {
515517
public layout({ height, width }: { height: number; width: number }): void {
516518
this._availableHeight = height;
517519
this._minimumWidth = width;
518-
this._listContainer.style.width = `${this._minimumWidth}px`;
519520
}
520521

521522
public setCandidates(candidates: NewSymbolName[]): void {
@@ -613,8 +614,7 @@ class CandidatesView {
613614
}
614615

615616
private _pickListWidth(candidates: NewSymbolName[]): number {
616-
const APPROXIMATE_CHAR_WIDTH = 7.2; // approximate # of pixes taken by a single character
617-
const longestCandidateWidth = Math.ceil(Math.max(...candidates.map(c => c.newSymbolName.length)) * APPROXIMATE_CHAR_WIDTH); // TODO@ulugbekna: use editor#typicalCharacterWidth or something
617+
const longestCandidateWidth = Math.ceil(Math.max(...candidates.map(c => c.newSymbolName.length)) * this._typicalHalfwidthCharacterWidth);
618618
const width = Math.max(
619619
this._minimumWidth,
620620
4 /* padding */ + 16 /* sparkle icon */ + 5 /* margin-left */ + longestCandidateWidth + 10 /* (possibly visible) scrollbar width */ // TODO@ulugbekna: approximate calc - clean this up

0 commit comments

Comments
 (0)