From 02fa69d25119674ee6a1b5b013e6e3fd0a0bc7be Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 3 Feb 2017 13:46:29 +0100 Subject: [PATCH] Fixes #19808: Block cursor is not rendered properly (visual glitches) --- src/vs/editor/browser/viewParts/lines/viewLine.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index 50dc2f4f947..37fd33bf325 100644 --- a/src/vs/editor/browser/viewParts/lines/viewLine.ts +++ b/src/vs/editor/browser/viewParts/lines/viewLine.ts @@ -220,6 +220,8 @@ export class ViewLine implements IVisibleLine { } public getVisibleRangesForRange(startColumn: number, endColumn: number, context: DomReadingContext): HorizontalRange[] { + startColumn = Math.min(this._renderedViewLine.input.lineContent.length + 1, Math.max(1, startColumn)); + endColumn = Math.min(this._renderedViewLine.input.lineContent.length + 1, Math.max(1, endColumn)); return this._renderedViewLine.getVisibleRangesForRange(startColumn, endColumn, context); } @@ -440,6 +442,11 @@ class RenderedViewLine { } protected _readPixelOffset(column: number, context: DomReadingContext): number { + if (this._characterMapping.length === 0) { + // This line is empty + return 0; + } + if (this._pixelOffsetCache !== null) { // the text is LTR @@ -458,11 +465,6 @@ class RenderedViewLine { private _actualReadPixelOffset(column: number, context: DomReadingContext): number { - if (this._characterMapping.length === 0) { - // This line is empty - return 0; - } - if (column === this._characterMapping.length && this._isWhitespaceOnly) { // This branch helps in the case of whitespace only lines which have a width set return this.getWidth(); -- GitLab