From c34838277d68bd19f0b97ecede4d86c684a111b8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 5 Jun 2015 19:55:34 +0200 Subject: [PATCH] =?UTF-8?q?In=20largeFileMode,=20base=20maxLineLength=20on?= =?UTF-8?q?=20the=20longest=20line=20we=E2=80=99ve=20seen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is pretty hacky. If we want to compute the true longest line, we’ll need to process every line, which is what large file mode is designed to avoid. So now whenever the display buffer returns a line, it has the potential to update the longest line. This is a bit weird because retrieving a line now has a side effect. It’s even more weird because the longest line will actually be wrong for the initial state updates in the TextEditorPresenter. But as soon as the user interacts in any way the dimensions are recomputed, so it works for now. A better approach may be to set a visible region on the display buffer. But I’d like to keep this low-touch until we have a chance to revisit the design of DisplayBuffer in a bigger way. --- src/display-buffer.coffee | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 32f374776..388182c8f 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -479,7 +479,11 @@ class DisplayBuffer extends Model # Returns {TokenizedLine} tokenizedLineForScreenRow: (screenRow) -> if @largeFileMode - @tokenizedBuffer.tokenizedLineForRow(screenRow) + line = @tokenizedBuffer.tokenizedLineForRow(screenRow) + if line.text.length > @maxLineLength + @maxLineLength = line.text.length + @longestScreenRow = screenRow + line else @screenLines[screenRow] @@ -760,19 +764,13 @@ class DisplayBuffer extends Model # # Returns a {Number}. getMaxLineLength: -> - if @largeFileMode - 100 - else - @maxLineLength + @maxLineLength # Gets the row number of the longest screen line. # # Return a {} getLongestScreenRow: -> - if @largeFileMode - 0 - else - @longestScreenRow + @longestScreenRow # Given a buffer position, this converts it into a screen position. #