Skip to content

Commit

Permalink
Add +1 to the visible textarea width to avoid flickering that might b…
Browse files Browse the repository at this point in the history
…e caused by accumulating rounding errors (microsoft#141725)
  • Loading branch information
alexdima committed Feb 25, 2022
1 parent 35af2cd commit a3dce15
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vs/editor/browser/controller/textAreaHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,14 @@ export class TextAreaHandler extends ViewPart {

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

0 comments on commit a3dce15

Please sign in to comment.