diff --git a/src/vs/editor/browser/viewParts/lines/viewLine.ts b/src/vs/editor/browser/viewParts/lines/viewLine.ts index 50dc2f4f947154c7f0f7c1a54e199536ab1a1915..37fd33bf325019a16ca790a2dba58c80ab85f16c 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();