Skip to content

Commit 02fa69d

Browse files
committed
Fixes #19808: Block cursor is not rendered properly (visual glitches)
1 parent 0a7e221 commit 02fa69d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ export class ViewLine implements IVisibleLine {
220220
}
221221

222222
public getVisibleRangesForRange(startColumn: number, endColumn: number, context: DomReadingContext): HorizontalRange[] {
223+
startColumn = Math.min(this._renderedViewLine.input.lineContent.length + 1, Math.max(1, startColumn));
224+
endColumn = Math.min(this._renderedViewLine.input.lineContent.length + 1, Math.max(1, endColumn));
223225
return this._renderedViewLine.getVisibleRangesForRange(startColumn, endColumn, context);
224226
}
225227

@@ -440,6 +442,11 @@ class RenderedViewLine {
440442
}
441443

442444
protected _readPixelOffset(column: number, context: DomReadingContext): number {
445+
if (this._characterMapping.length === 0) {
446+
// This line is empty
447+
return 0;
448+
}
449+
443450
if (this._pixelOffsetCache !== null) {
444451
// the text is LTR
445452

@@ -458,11 +465,6 @@ class RenderedViewLine {
458465

459466
private _actualReadPixelOffset(column: number, context: DomReadingContext): number {
460467

461-
if (this._characterMapping.length === 0) {
462-
// This line is empty
463-
return 0;
464-
}
465-
466468
if (column === this._characterMapping.length && this._isWhitespaceOnly) {
467469
// This branch helps in the case of whitespace only lines which have a width set
468470
return this.getWidth();

0 commit comments

Comments
 (0)