diff --git a/spec/atom/line-wrapper-spec.coffee b/spec/atom/line-wrapper-spec.coffee index 9730e000e..8987f9577 100644 --- a/spec/atom/line-wrapper-spec.coffee +++ b/spec/atom/line-wrapper-spec.coffee @@ -1,6 +1,7 @@ -Buffer = require 'buffer' LineWrapper = require 'line-wrapper' +Buffer = require 'buffer' Highlighter = require 'highlighter' +LineFolder = require 'line-folder' Range = require 'range' ScreenLineFragment = require 'screen-line-fragment' _ = require 'underscore' @@ -10,7 +11,9 @@ describe "LineWrapper", -> beforeEach -> buffer = new Buffer(require.resolve('fixtures/sample.js')) - wrapper = new LineWrapper(50, new Highlighter(buffer)) + highlighter = new Highlighter(buffer) + folder = new LineFolder(highlighter) + wrapper = new LineWrapper(50, folder) changeHandler = jasmine.createSpy('changeHandler') wrapper.on 'change', changeHandler diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index 3c4572ef7..6b8d78b63 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -4,6 +4,7 @@ Point = require 'point' Cursor = require 'cursor' Selection = require 'selection' Highlighter = require 'highlighter' +LineFolder = require 'line-folder' LineWrapper = require 'line-wrapper' UndoManager = require 'undo-manager' Range = require 'range' @@ -134,7 +135,8 @@ class Editor extends View setBuffer: (@buffer) -> @highlighter = new Highlighter(@buffer) - @lineWrapper = new LineWrapper(Infinity, @highlighter) + @lineFolder = new LineFolder(@highlighter) + @lineWrapper = new LineWrapper(Infinity, @lineFolder) @undoManager = new UndoManager(@buffer) @renderLines() @setCursorPosition(row: 0, column: 0) diff --git a/src/atom/line-wrapper.coffee b/src/atom/line-wrapper.coffee index 16ee097a4..b6c0830a1 100644 --- a/src/atom/line-wrapper.coffee +++ b/src/atom/line-wrapper.coffee @@ -6,9 +6,9 @@ Range = require 'range' module.exports = class LineWrapper - constructor: (@maxLength, @highlighter) -> + constructor: (@maxLength, @lineFolder) -> @buildLineMap() - @highlighter.on 'change', (e) => @handleChange(e) + @lineFolder.on 'change', (e) => @handleChange(e) setMaxLength: (@maxLength) -> oldRange = @rangeForAllLines() @@ -18,7 +18,7 @@ class LineWrapper buildLineMap: -> @lineMap = new LineMap - @lineMap.insertAtBufferRow 0, @buildScreenLinesForBufferRows(0, @highlighter.lastRow()) + @lineMap.insertAtBufferRow 0, @buildScreenLinesForBufferRows(0, @lineFolder.lastRow()) handleChange: (e) -> oldBufferRange = e.oldRange @@ -41,7 +41,7 @@ class LineWrapper new Range([0, 0], [endRow, endColumn]) buildScreenLinesForBufferRows: (start, end) -> - _(@highlighter + _(@lineFolder .linesForScreenRows(start, end) .map((screenLine) => @wrapScreenLine(screenLine))).flatten()