From e5165814e691e5844d00068f7b388e3e49dbe6d4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 19 Nov 2015 16:32:38 -0800 Subject: [PATCH 1/3] Return early in FakeLinesYardstick for unrendered rows This allows us to have a more consistent behavior with the real LinesYardstick. --- spec/fake-lines-yardstick.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/fake-lines-yardstick.coffee b/spec/fake-lines-yardstick.coffee index 9934b1917..1872b8c65 100644 --- a/spec/fake-lines-yardstick.coffee +++ b/spec/fake-lines-yardstick.coffee @@ -7,6 +7,7 @@ class FakeLinesYardstick prepareScreenRowsForMeasurement: -> @presenter.getPreMeasurementState() + @screenRows = new Set(@presenter.getScreenRows()) getScopedCharacterWidth: (scopeNames, char) -> @getScopedCharacterWidths(scopeNames)[char] @@ -34,6 +35,8 @@ class FakeLinesYardstick left = 0 column = 0 + return {top, left: 0} unless @screenRows.has(screenPosition.row) + iterator = @model.tokenizedLineForScreenRow(targetRow).getTokenIterator() while iterator.next() characterWidths = @getScopedCharacterWidths(iterator.getScopes()) From cbfee4e8097bffb6ed38143b18eb6d58226efc84 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 19 Nov 2015 16:38:19 -0800 Subject: [PATCH 2/3] :bug: Compute content width when the longest row is the first one --- spec/text-editor-presenter-spec.coffee | 14 ++++++++++++++ src/text-editor-presenter.coffee | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 1804b7b6b..34b8d2443 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -680,6 +680,20 @@ describe "TextEditorPresenter", -> presenter = buildPresenter(explicitHeight: 100, contentFrameWidth: 10 * maxLineLength + 20, baseCharacterWidth: 10, verticalScrollbarWidth: 10) expect(presenter.getState().content.scrollWidth).toBe 10 * maxLineLength + 20 - 10 # subtract vertical scrollbar width + describe "when the longest screen row is the first one and it's hidden", -> + it "doesn't compute an invalid value (regression)", -> + presenter = buildPresenter(tileSize: 2, contentFrameWidth: 10, explicitHeight: 20) + editor.setText """ + a very long long long long long long line + b + c + d + e + """ + + expectStateUpdate presenter, -> presenter.setScrollTop(40) + expect(presenter.getState().content.scrollWidth).toBe 10 * editor.getMaxScreenLineLength() + 1 + it "updates when the ::contentFrameWidth changes", -> maxLineLength = editor.getMaxScreenLineLength() presenter = buildPresenter(contentFrameWidth: 50, baseCharacterWidth: 10) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 2e1d73c56..724e8b723 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -380,7 +380,8 @@ class TextEditorPresenter endRow = @constrainRow(@getEndTileRow() + @tileSize) screenRows = [startRow...endRow] - if longestScreenRow = @model.getLongestScreenRow() + longestScreenRow = @model.getLongestScreenRow() + if longestScreenRow? screenRows.push(longestScreenRow) if @screenRowsToMeasure? screenRows.push(@screenRowsToMeasure...) From 1c90cbfae2bfbd4b7070eb133aadebe8d945e5b3 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 20 Nov 2015 10:45:40 -0700 Subject: [PATCH 3/3] 1.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cd970440d..d7787fe1e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom", "productName": "Atom", - "version": "1.2.3", + "version": "1.2.4", "description": "A hackable text editor for the 21st Century.", "main": "./src/browser/main.js", "repository": {