diff --git a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts index ccf43d5b6949c..a02902a396559 100644 --- a/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts +++ b/src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts @@ -101,15 +101,6 @@ export class LineNumbersOverlay extends DynamicViewOverlay { } const modelLineNumber = modelPosition.lineNumber; - if (!this._renderFinalNewline) { - const lineCount = this._context.model.getLineCount(); - const lineContent = this._context.model.getLineContent(modelLineNumber); - - if (modelLineNumber === lineCount && lineContent === '') { - return ''; - } - } - if (this._renderCustomLineNumbers) { return this._renderCustomLineNumbers(modelLineNumber); } @@ -146,10 +137,19 @@ export class LineNumbersOverlay extends DynamicViewOverlay { const visibleEndLineNumber = ctx.visibleRange.endLineNumber; const common = '
'; + const lineCount = this._context.model.getLineCount(); const output: string[] = []; for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) { const lineIndex = lineNumber - visibleStartLineNumber; + if (!this._renderFinalNewline) { + if (lineNumber === lineCount && this._context.model.getLineLength(lineNumber) === 0) { + // Do not render last (empty) line + output[lineIndex] = ''; + continue; + } + } + const renderLineNumber = this._getLineRenderLineNumber(lineNumber); if (renderLineNumber) {