Skip to content

Commit 35dfc70

Browse files
committed
Fixes microsoft#90915: Try to correct browser rounding errors
1 parent 305fbc1 commit 35dfc70

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/vs/editor/browser/viewParts/lines/viewLine.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,15 @@ class RenderedViewLine implements IRenderedViewLine {
616616
if (!r || r.length === 0) {
617617
return -1;
618618
}
619-
return r[0].left;
619+
const result = r[0].left;
620+
if (this.input.isBasicASCII) {
621+
const charOffset = this._characterMapping.getAbsoluteOffsets();
622+
const expectedResult = Math.round(this.input.spaceWidth * charOffset[column - 1]);
623+
if (Math.abs(expectedResult - result) <= 1) {
624+
return expectedResult;
625+
}
626+
}
627+
return result;
620628
}
621629

622630
private _readRawVisibleRangesForRange(domNode: FastDomNode<HTMLElement>, startColumn: number, endColumn: number, context: DomReadingContext): HorizontalRange[] | null {

0 commit comments

Comments
 (0)