mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
In largeFileMode, base maxLineLength on the longest line we’ve seen
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.
This commit is contained in:
@@ -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.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user