Skip to content

Commit a3dce15

Browse files
committed
Add +1 to the visible textarea width to avoid flickering that might be caused by accumulating rounding errors (microsoft#141725)
1 parent 35af2cd commit a3dce15

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/vs/editor/browser/controller/textAreaHandler.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,14 @@ export class TextAreaHandler extends ViewPart {
650650

651651
let scrollLeft = this._visibleTextArea.widthOfHiddenLineTextBefore;
652652
let left = (this._contentLeft + visibleStart.left - this._scrollLeft);
653-
let width = visibleEnd.left - visibleStart.left;
653+
// See https://github.com/microsoft/vscode/issues/141725#issuecomment-1050670841
654+
// Here we are adding +1 to avoid flickering that might be caused by having a width that is too small.
655+
// This could be caused by rounding errors that might only show up with certain font families.
656+
// In other words, a pixel might be lost when doing something like
657+
// `Math.round(end) - Math.round(start)`
658+
// vs
659+
// `Math.round(end - start)`
660+
let width = visibleEnd.left - visibleStart.left + 1;
654661
if (left < this._contentLeft) {
655662
// the textarea would be rendered on top of the margin,
656663
// so reduce its width. We use the same technique as

0 commit comments

Comments
 (0)