From 43f27780fd25f7cd7e00c61a057402a3d91742ad Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 17 Mar 2016 14:56:23 +0100 Subject: [PATCH] Fix specs related to the produced HTML line output This verifies that with the new DisplayLayer the produced output is cleaner when tags interleave. --- spec/text-editor-component-spec.js | 18 +++++++++--------- src/text-editor-presenter.coffee | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index d806b872e..ffcf38ea2 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -483,7 +483,7 @@ describe('TextEditorComponent', function () { it('displays newlines as their own token outside of the other tokens\' scopeDescriptor', async function () { editor.setText('let\n') await nextViewUpdatePromise() - expect(component.lineNodeForScreenRow(0).innerHTML).toBe('let' + invisibles.eol + '') + expect(component.lineNodeForScreenRow(0).innerHTML).toBe('let' + invisibles.eol + '') }) it('displays trailing carriage returns using a visible, non-empty value', async function () { @@ -522,19 +522,19 @@ describe('TextEditorComponent', function () { }) await nextViewUpdatePromise() - expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE') + expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE ') editor.setTabLength(3) await nextViewUpdatePromise() - expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE ') + expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE ') editor.setTabLength(1) await nextViewUpdatePromise() - expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE') + expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE ') editor.setTextInBufferRange([[9, 0], [9, Infinity]], ' ') editor.setTextInBufferRange([[11, 0], [11, Infinity]], ' ') await nextViewUpdatePromise() - expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE') + expect(component.lineNodeForScreenRow(10).innerHTML).toBe('CE') }) describe('when soft wrapping is enabled', function () { @@ -1198,10 +1198,10 @@ describe('TextEditorComponent', function () { let cursor = componentNode.querySelector('.cursor') let cursorRect = cursor.getBoundingClientRect() - let cursorLocationTextNode = component.lineNodeForScreenRow(0).querySelector('.source.js').childNodes[2] - let range = document.createRange() - range.setStart(cursorLocationTextNode, 0) - range.setEnd(cursorLocationTextNode, 1) + let cursorLocationTextNode = component.lineNodeForScreenRow(0).querySelector('.source.js').childNodes[0] + let range = document.createRange(cursorLocationTextNode) + range.setStart(cursorLocationTextNode, 3) + range.setEnd(cursorLocationTextNode, 4) let rangeRect = range.getBoundingClientRect() expect(cursorRect.left).toBeCloseTo(rangeRect.left, 0) expect(cursorRect.width).toBeCloseTo(rangeRect.width, 0) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 6240f4a37..9ff1e5970 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -1075,7 +1075,7 @@ class TextEditorPresenter @linesByScreenRow.set(startRow + index, line) lineIdForScreenRow: (screenRow) -> - @linesByScreenRow.get(screenRow).id + @linesByScreenRow.get(screenRow)?.id fetchDecorations: -> return unless 0 <= @startRow <= @endRow <= Infinity