mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
wip: what nathan and corey did
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
RootView = require 'root-view'
|
||||
RootView = require 'root-view'
|
||||
Buffer = require 'buffer'
|
||||
Editor = require 'editor'
|
||||
Range = require 'range'
|
||||
@@ -2422,47 +2422,36 @@ describe "Editor", ->
|
||||
|
||||
describe "folding", ->
|
||||
beforeEach ->
|
||||
editor.setBuffer(new Buffer(require.resolve('fixtures/two-hundred.txt')))
|
||||
editor.attachToDom()
|
||||
|
||||
describe "when a fold-selection event is triggered", ->
|
||||
it "folds the selected text and moves the cursor to just after the placeholder, then treats the placeholder as a single character", ->
|
||||
fit "folds the lines covered by the selection into a single line with a fold class", ->
|
||||
editor.getSelection().setBufferRange(new Range([4, 29], [7, 4]))
|
||||
editor.trigger 'fold-selection'
|
||||
|
||||
expect(editor.visibleLines.find('.line:eq(4)').find('.fold-placeholder')).toExist()
|
||||
expect(editor.visibleLines.find('.line:eq(5)').text()).toBe ' return sort(left).concat(pivot).concat(sort(right));'
|
||||
expect(editor.visibleLines.find('.line:eq(4)').toHaveClass('fold')
|
||||
expect(editor.visibleLines.find('.line:eq(5)').text()).toBe '8'
|
||||
|
||||
expect(editor.getSelection().isEmpty()).toBeTruthy()
|
||||
expect(editor.getCursorScreenPosition()).toEqual [4, 32]
|
||||
expect(editor.getCursorScreenPosition()).toEqual [5, 0]
|
||||
|
||||
editor.setCursorBufferPosition([9, 4])
|
||||
expect(editor.getCursorScreenPosition()).toEqual [6, 4]
|
||||
# describe "when a fold placeholder is clicked", ->
|
||||
# it "removes the associated fold and places the cursor at its beginning", ->
|
||||
# editor.getSelection().setBufferRange(new Range([4, 29], [7, 4]))
|
||||
# editor.trigger 'fold-selection'
|
||||
|
||||
editor.insertText('x')
|
||||
expect(editor.getCursorScreenPosition()).toEqual [6, 5]
|
||||
expect(editor.getCursorBufferPosition()).toEqual [9, 5]
|
||||
# editor.find('.fold-placeholder .ellipsis').mousedown()
|
||||
|
||||
editor.setCursorScreenPosition([4, 30])
|
||||
expect(editor.getCursorScreenPosition()).toEqual [4, 29]
|
||||
editor.moveCursorRight()
|
||||
expect(editor.getCursorScreenPosition()).toEqual [4, 32]
|
||||
# expect(editor.find('.fold-placeholder')).not.toExist()
|
||||
# expect(editor.visibleLines.find('.line:eq(5)').text()).toBe ' current = items.shift();'
|
||||
|
||||
describe "when a fold placeholder is clicked", ->
|
||||
it "removes the associated fold and places the cursor at its beginning", ->
|
||||
editor.getSelection().setBufferRange(new Range([4, 29], [7, 4]))
|
||||
editor.trigger 'fold-selection'
|
||||
# expect(editor.getCursorBufferPosition()).toEqual [4, 29]
|
||||
|
||||
editor.find('.fold-placeholder .ellipsis').mousedown()
|
||||
|
||||
expect(editor.find('.fold-placeholder')).not.toExist()
|
||||
expect(editor.visibleLines.find('.line:eq(5)').text()).toBe ' current = items.shift();'
|
||||
|
||||
expect(editor.getCursorBufferPosition()).toEqual [4, 29]
|
||||
|
||||
describe "when there is nothing on a line except a fold placeholder", ->
|
||||
it "follows the placeholder with a non-breaking space to ensure the line has the proper height", ->
|
||||
editor.createFold([[1, 0], [1, 30]])
|
||||
expect(editor.visibleLines.find('.line:eq(1)').html()).toMatch / $/
|
||||
# describe "when there is nothing on a line except a fold placeholder", ->
|
||||
# it "follows the placeholder with a non-breaking space to ensure the line has the proper height", ->
|
||||
# editor.createFold([[1, 0], [1, 30]])
|
||||
# expect(editor.visibleLines.find('.line:eq(1)').html()).toMatch / $/
|
||||
|
||||
describe "editor-path-change event", ->
|
||||
it "emits event when buffer's path is changed", ->
|
||||
|
||||
@@ -222,31 +222,34 @@ describe "Renderer", ->
|
||||
expect(event.newRange).toEqual([[0, 0], [18, 2]])
|
||||
|
||||
describe "folding", ->
|
||||
beforeEach ->
|
||||
buffer = new Buffer(require.resolve 'fixtures/two-hundred.js')
|
||||
renderer = new Renderer(buffer, {tabText})
|
||||
|
||||
describe "when folds are created and destroyed", ->
|
||||
describe "when a fold spans multiple lines", ->
|
||||
it "replaces the lines spanned by the fold with a single line containing a placeholder", ->
|
||||
previousLine4Text = renderer.lineForRow(4).text
|
||||
previousLine5Text = renderer.lineForRow(5).text
|
||||
fit "replaces the lines spanned by the fold with a single line with a html class of 'fold'", ->
|
||||
fold = renderer.createFold(4, 7)
|
||||
|
||||
fold = renderer.createFold([[4, 29], [7, 4]])
|
||||
|
||||
expect(renderer.lineForRow(4).text).toBe ' while(items.length > 0) {...}'
|
||||
expect(renderer.lineForRow(5).text).toBe ' return sort(left).concat(pivot).concat(sort(right));'
|
||||
expect(renderer.lineForRow(4).text).toHaveClass('fold')
|
||||
expect(renderer.lineForRow(4).text).toMatch /^4-+/
|
||||
expect(renderer.lineForRow(5).text).toBe '8'
|
||||
|
||||
expect(changeHandler).toHaveBeenCalled()
|
||||
[event] = changeHandler.argsForCall[0]
|
||||
expect(event.oldRange).toEqual [[4, 0], [7, 5]]
|
||||
expect(event.newRange).toEqual [[4, 0], [4, 33]]
|
||||
expect(event.oldRange).toEqual [[4, 0], [7, 1]]
|
||||
expect(event.newRange).toEqual [[4, 0], [4, 101]]
|
||||
changeHandler.reset()
|
||||
|
||||
fold.destroy()
|
||||
expect(renderer.lineForRow(4).text).toBe previousLine4Text
|
||||
expect(renderer.lineForRow(5).text).toBe previousLine5Text
|
||||
expect(renderer.lineForRow(4).text).not.toHaveClass('fold')
|
||||
expect(renderer.lineForRow(4).text).toMatch /^4-+/
|
||||
expect(renderer.lineForRow(5).text).toBe '5'
|
||||
|
||||
expect(changeHandler).toHaveBeenCalled()
|
||||
[[event]] = changeHandler.argsForCall
|
||||
expect(event.oldRange).toEqual [[4, 0], [4, 33]]
|
||||
expect(event.newRange).toEqual [[4, 0], [7, 5]]
|
||||
expect(event.oldRange).toEqual [[4, 0], [4, 101]]
|
||||
expect(event.newRange).toEqual [[4, 0], [7, 1]]
|
||||
|
||||
describe "when a fold spans a single line", ->
|
||||
it "renders a placeholder for the folded region, but does not skip any lines", ->
|
||||
|
||||
200
spec/fixtures/two-hundred-zero-indexed.txt
vendored
200
spec/fixtures/two-hundred-zero-indexed.txt
vendored
@@ -1,200 +0,0 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4----------------------------------------------------------------------------------------------------
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9----------------------------------------------------------------------------------------------------
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14----------------------------------------------------------------------------------------------------
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19----------------------------------------------------------------------------------------------------
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24----------------------------------------------------------------------------------------------------
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29----------------------------------------------------------------------------------------------------
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34----------------------------------------------------------------------------------------------------
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39----------------------------------------------------------------------------------------------------
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44----------------------------------------------------------------------------------------------------
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49----------------------------------------------------------------------------------------------------
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54----------------------------------------------------------------------------------------------------
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59----------------------------------------------------------------------------------------------------
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64----------------------------------------------------------------------------------------------------
|
||||
65
|
||||
66
|
||||
67
|
||||
68
|
||||
69----------------------------------------------------------------------------------------------------
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74----------------------------------------------------------------------------------------------------
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79----------------------------------------------------------------------------------------------------
|
||||
80
|
||||
81
|
||||
82
|
||||
83
|
||||
84----------------------------------------------------------------------------------------------------
|
||||
85
|
||||
86
|
||||
87
|
||||
88
|
||||
89----------------------------------------------------------------------------------------------------
|
||||
90
|
||||
91
|
||||
92
|
||||
93
|
||||
94----------------------------------------------------------------------------------------------------
|
||||
95
|
||||
96
|
||||
97
|
||||
98
|
||||
99----------------------------------------------------------------------------------------------------
|
||||
100
|
||||
101
|
||||
102
|
||||
103
|
||||
104----------------------------------------------------------------------------------------------------
|
||||
105
|
||||
106
|
||||
107
|
||||
108
|
||||
109----------------------------------------------------------------------------------------------------
|
||||
110
|
||||
111
|
||||
112
|
||||
113
|
||||
114----------------------------------------------------------------------------------------------------
|
||||
115
|
||||
116
|
||||
117
|
||||
118
|
||||
119----------------------------------------------------------------------------------------------------
|
||||
120
|
||||
121
|
||||
122
|
||||
123
|
||||
124----------------------------------------------------------------------------------------------------
|
||||
125
|
||||
126
|
||||
127
|
||||
128
|
||||
129----------------------------------------------------------------------------------------------------
|
||||
130
|
||||
131
|
||||
132
|
||||
133
|
||||
134----------------------------------------------------------------------------------------------------
|
||||
135
|
||||
136
|
||||
137
|
||||
138
|
||||
139----------------------------------------------------------------------------------------------------
|
||||
140
|
||||
141
|
||||
142
|
||||
143
|
||||
144----------------------------------------------------------------------------------------------------
|
||||
145
|
||||
146
|
||||
147
|
||||
148
|
||||
149----------------------------------------------------------------------------------------------------
|
||||
150
|
||||
151
|
||||
152
|
||||
153
|
||||
154----------------------------------------------------------------------------------------------------
|
||||
155
|
||||
156
|
||||
157
|
||||
158
|
||||
159----------------------------------------------------------------------------------------------------
|
||||
160
|
||||
161
|
||||
162
|
||||
163
|
||||
164----------------------------------------------------------------------------------------------------
|
||||
165
|
||||
166
|
||||
167
|
||||
168
|
||||
169----------------------------------------------------------------------------------------------------
|
||||
170
|
||||
171
|
||||
172
|
||||
173
|
||||
174----------------------------------------------------------------------------------------------------
|
||||
175
|
||||
176
|
||||
177
|
||||
178
|
||||
179----------------------------------------------------------------------------------------------------
|
||||
180
|
||||
181
|
||||
182
|
||||
183
|
||||
184----------------------------------------------------------------------------------------------------
|
||||
185
|
||||
186
|
||||
187
|
||||
188
|
||||
189----------------------------------------------------------------------------------------------------
|
||||
190
|
||||
191
|
||||
192
|
||||
193
|
||||
194----------------------------------------------------------------------------------------------------
|
||||
195
|
||||
196
|
||||
197
|
||||
198
|
||||
199----------------------------------------------------------------------------------------------------
|
||||
160
spec/fixtures/two-hundred.txt
vendored
160
spec/fixtures/two-hundred.txt
vendored
@@ -1,200 +1,200 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5....................................................................................................
|
||||
4----------------------------------------------------------------------------------------------------
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10....................................................................................................
|
||||
9----------------------------------------------------------------------------------------------------
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15....................................................................................................
|
||||
14----------------------------------------------------------------------------------------------------
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20....................................................................................................
|
||||
19----------------------------------------------------------------------------------------------------
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25....................................................................................................
|
||||
24----------------------------------------------------------------------------------------------------
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30....................................................................................................
|
||||
29----------------------------------------------------------------------------------------------------
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35....................................................................................................
|
||||
34----------------------------------------------------------------------------------------------------
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
40....................................................................................................
|
||||
39----------------------------------------------------------------------------------------------------
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45....................................................................................................
|
||||
44----------------------------------------------------------------------------------------------------
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49
|
||||
50....................................................................................................
|
||||
49----------------------------------------------------------------------------------------------------
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54
|
||||
55....................................................................................................
|
||||
54----------------------------------------------------------------------------------------------------
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59
|
||||
60....................................................................................................
|
||||
59----------------------------------------------------------------------------------------------------
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64
|
||||
65....................................................................................................
|
||||
64----------------------------------------------------------------------------------------------------
|
||||
65
|
||||
66
|
||||
67
|
||||
68
|
||||
69
|
||||
70....................................................................................................
|
||||
69----------------------------------------------------------------------------------------------------
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74
|
||||
75....................................................................................................
|
||||
74----------------------------------------------------------------------------------------------------
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79
|
||||
80....................................................................................................
|
||||
79----------------------------------------------------------------------------------------------------
|
||||
80
|
||||
81
|
||||
82
|
||||
83
|
||||
84
|
||||
85....................................................................................................
|
||||
84----------------------------------------------------------------------------------------------------
|
||||
85
|
||||
86
|
||||
87
|
||||
88
|
||||
89
|
||||
90....................................................................................................
|
||||
89----------------------------------------------------------------------------------------------------
|
||||
90
|
||||
91
|
||||
92
|
||||
93
|
||||
94
|
||||
95....................................................................................................
|
||||
94----------------------------------------------------------------------------------------------------
|
||||
95
|
||||
96
|
||||
97
|
||||
98
|
||||
99
|
||||
100....................................................................................................
|
||||
99----------------------------------------------------------------------------------------------------
|
||||
100
|
||||
101
|
||||
102
|
||||
103
|
||||
104
|
||||
105....................................................................................................
|
||||
104----------------------------------------------------------------------------------------------------
|
||||
105
|
||||
106
|
||||
107
|
||||
108
|
||||
109
|
||||
110....................................................................................................
|
||||
109----------------------------------------------------------------------------------------------------
|
||||
110
|
||||
111
|
||||
112
|
||||
113
|
||||
114
|
||||
115....................................................................................................
|
||||
114----------------------------------------------------------------------------------------------------
|
||||
115
|
||||
116
|
||||
117
|
||||
118
|
||||
119
|
||||
120....................................................................................................
|
||||
119----------------------------------------------------------------------------------------------------
|
||||
120
|
||||
121
|
||||
122
|
||||
123
|
||||
124
|
||||
125....................................................................................................
|
||||
124----------------------------------------------------------------------------------------------------
|
||||
125
|
||||
126
|
||||
127
|
||||
128
|
||||
129
|
||||
130....................................................................................................
|
||||
129----------------------------------------------------------------------------------------------------
|
||||
130
|
||||
131
|
||||
132
|
||||
133
|
||||
134
|
||||
135....................................................................................................
|
||||
134----------------------------------------------------------------------------------------------------
|
||||
135
|
||||
136
|
||||
137
|
||||
138
|
||||
139
|
||||
140....................................................................................................
|
||||
139----------------------------------------------------------------------------------------------------
|
||||
140
|
||||
141
|
||||
142
|
||||
143
|
||||
144
|
||||
145....................................................................................................
|
||||
144----------------------------------------------------------------------------------------------------
|
||||
145
|
||||
146
|
||||
147
|
||||
148
|
||||
149
|
||||
150....................................................................................................
|
||||
149----------------------------------------------------------------------------------------------------
|
||||
150
|
||||
151
|
||||
152
|
||||
153
|
||||
154
|
||||
155....................................................................................................
|
||||
154----------------------------------------------------------------------------------------------------
|
||||
155
|
||||
156
|
||||
157
|
||||
158
|
||||
159
|
||||
160....................................................................................................
|
||||
159----------------------------------------------------------------------------------------------------
|
||||
160
|
||||
161
|
||||
162
|
||||
163
|
||||
164
|
||||
165....................................................................................................
|
||||
164----------------------------------------------------------------------------------------------------
|
||||
165
|
||||
166
|
||||
167
|
||||
168
|
||||
169
|
||||
170....................................................................................................
|
||||
169----------------------------------------------------------------------------------------------------
|
||||
170
|
||||
171
|
||||
172
|
||||
173
|
||||
174
|
||||
175....................................................................................................
|
||||
174----------------------------------------------------------------------------------------------------
|
||||
175
|
||||
176
|
||||
177
|
||||
178
|
||||
179
|
||||
180....................................................................................................
|
||||
179----------------------------------------------------------------------------------------------------
|
||||
180
|
||||
181
|
||||
182
|
||||
183
|
||||
184
|
||||
185....................................................................................................
|
||||
184----------------------------------------------------------------------------------------------------
|
||||
185
|
||||
186
|
||||
187
|
||||
188
|
||||
189
|
||||
190....................................................................................................
|
||||
189----------------------------------------------------------------------------------------------------
|
||||
190
|
||||
191
|
||||
192
|
||||
193
|
||||
194
|
||||
195....................................................................................................
|
||||
194----------------------------------------------------------------------------------------------------
|
||||
195
|
||||
196
|
||||
197
|
||||
198
|
||||
199
|
||||
200....................................................................................................
|
||||
199----------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -522,8 +522,8 @@ class Editor extends View
|
||||
maxLineLength ?= @calcMaxLineLength()
|
||||
@renderer.setMaxLineLength(maxLineLength) if maxLineLength
|
||||
|
||||
createFold: (range) ->
|
||||
@renderer.createFold(range)
|
||||
createFold: (startRow, endRow) ->
|
||||
@renderer.createFold(startRow, endRow)
|
||||
|
||||
setSoftWrap: (@softWrap, maxLineLength=undefined) ->
|
||||
@setMaxLineLength(maxLineLength) if @attached
|
||||
|
||||
@@ -3,49 +3,53 @@ Range = require 'range'
|
||||
module.exports =
|
||||
class Fold
|
||||
@idCounter: 1
|
||||
start: null
|
||||
end: null
|
||||
|
||||
constructor: (@lineFolder, {@start, @end}) ->
|
||||
renderer: null
|
||||
startRow: null
|
||||
endRow: null
|
||||
|
||||
constructor: (@renderer, @startRow, @endRow) ->
|
||||
@id = @constructor.idCounter++
|
||||
|
||||
destroy: ->
|
||||
@lineFolder.destroyFold(this)
|
||||
@renderer.destroyFold(this)
|
||||
|
||||
getRange: ->
|
||||
new Range(@start, @end)
|
||||
# new Range([@startRow, 0], @endRow)
|
||||
throw "Don't worry about this yet -- sobo"
|
||||
|
||||
handleBufferChange: (event) ->
|
||||
oldStartRow = @start.row
|
||||
# oldStartRow = @start.row
|
||||
|
||||
{ oldRange } = event
|
||||
if oldRange.start.isLessThanOrEqual(@start) and oldRange.end.isGreaterThanOrEqual(@end)
|
||||
@lineFolder.unregisterFold(oldStartRow, this)
|
||||
return
|
||||
# { oldRange } = event
|
||||
# if oldRange.start.isLessThanOrEqual(@start) and oldRange.end.isGreaterThanOrEqual(@end)
|
||||
# @renderer.unregisterFold(oldStartRow, this)
|
||||
# return
|
||||
|
||||
changeInsideFold = @start.isLessThanOrEqual(oldRange.start) and @end.isGreaterThan(oldRange.end)
|
||||
# changeInsideFold = @start.isLessThanOrEqual(oldRange.start) and @end.isGreaterThan(oldRange.end)
|
||||
|
||||
@start = @updateAnchorPoint(@start, event)
|
||||
@end = @updateAnchorPoint(@end, event, false)
|
||||
# @start = @updateAnchorPoint(@start, event)
|
||||
# @end = @updateAnchorPoint(@end, event, false)
|
||||
|
||||
if @start.row != oldStartRow
|
||||
@lineFolder.unregisterFold(oldStartRow, this)
|
||||
@lineFolder.registerFold(@start.row, this)
|
||||
# if @start.row != oldStartRow
|
||||
# @renderer.unregisterFold(oldStartRow, this)
|
||||
# @lineFolder.registerFold(@start.row, this)
|
||||
|
||||
changeInsideFold
|
||||
# changeInsideFold
|
||||
|
||||
updateAnchorPoint: (point, event, inclusive=true) ->
|
||||
{ newRange, oldRange } = event
|
||||
if inclusive
|
||||
return point if oldRange.end.isGreaterThan(point)
|
||||
else
|
||||
return point if oldRange.end.isGreaterThanOrEqual(point)
|
||||
# { newRange, oldRange } = event
|
||||
# if inclusive
|
||||
# return point if oldRange.end.isGreaterThan(point)
|
||||
# else
|
||||
# return point if oldRange.end.isGreaterThanOrEqual(point)
|
||||
|
||||
newRange.end.add(point.subtract(oldRange.end))
|
||||
# newRange.end.add(point.subtract(oldRange.end))
|
||||
|
||||
compare: (other) ->
|
||||
startComparison = @start.compare(other.start)
|
||||
if startComparison == 0
|
||||
other.end.compare(@end)
|
||||
else
|
||||
startComparison
|
||||
other
|
||||
# startComparison = @start.compare(other.start)
|
||||
# if startComparison == 0
|
||||
# other.end.compare(@end)
|
||||
# else
|
||||
# startComparison
|
||||
|
||||
@@ -51,23 +51,13 @@ class Renderer
|
||||
bufferRowsForScreenRows: (startRow, endRow) ->
|
||||
@lineMap.bufferRowsForScreenRows(startRow, endRow)
|
||||
|
||||
createFold: (bufferRange) ->
|
||||
bufferRange = Range.fromObject(bufferRange)
|
||||
return if bufferRange.isEmpty()
|
||||
|
||||
fold = new Fold(this, bufferRange)
|
||||
@registerFold(bufferRange.start.row, fold)
|
||||
|
||||
# If this fold starts on a screen line that contains other folds, we'll
|
||||
# need to the re-render the screen lines corresponding to these preceding
|
||||
# folds as well. So we alter the start row of the buffer range we
|
||||
# are going to change to the buffer row of the first fold in a potential
|
||||
# series of folds that ends on the current fold's starting buffer row.
|
||||
bufferRange = bufferRange.copy()
|
||||
bufferRange.start.row = @bufferRowForScreenRow(@screenRowForBufferRow(bufferRange.start.row))
|
||||
createFold: (startRow, endRow) ->
|
||||
fold = new Fold(this, startRow, endRow)
|
||||
@registerFold(startRow, fold)
|
||||
|
||||
bufferRange = new Range([[startRow, 0], [endRow, @buffer.lineLengthForRow(endRow)]])
|
||||
oldScreenRange = @screenLineRangeForBufferRange(bufferRange)
|
||||
lines = @buildLineForBufferRow(bufferRange.start.row)
|
||||
lines = @buildLineForBufferRow(startRow)
|
||||
@lineMap.replaceScreenRows(oldScreenRange.start.row, oldScreenRange.end.row, lines)
|
||||
newScreenRange = @screenLineRangeForBufferRange(bufferRange)
|
||||
|
||||
@@ -147,29 +137,20 @@ class Renderer
|
||||
startBufferColumn = null
|
||||
currentScreenLineLength = 0
|
||||
|
||||
loop
|
||||
break if startBufferRow > endBufferRow and not startBufferColumn?
|
||||
while startBufferRow <= endBufferRow
|
||||
break if
|
||||
startBufferColumn ?= 0
|
||||
line = @highlighter.lineForRow(startBufferRow)
|
||||
line = line.splitAt(startBufferColumn)[1]
|
||||
wrapScreenColumn = @findWrapColumn(line.text, @maxLineLength - currentScreenLineLength)
|
||||
|
||||
continueMainLoop = false
|
||||
for fold in @foldsForBufferRow(startBufferRow)
|
||||
if fold.start.column >= startBufferColumn
|
||||
foldStartSceenColumn = fold.start.column - startBufferColumn
|
||||
if (foldStartSceenColumn) > wrapScreenColumn - foldPlaceholderLength
|
||||
wrapScreenColumn = Math.min(wrapScreenColumn, foldStartSceenColumn)
|
||||
break
|
||||
prefix = line.splitAt(foldStartSceenColumn)[0]
|
||||
placeholder = @buildFoldPlaceholder(fold)
|
||||
lineFragments.push(prefix, placeholder)
|
||||
startBufferRow = fold.end.row
|
||||
startBufferColumn = fold.end.column
|
||||
currentScreenLineLength = currentScreenLineLength + (prefix?.text.length ? 0) + foldPlaceholderLength
|
||||
continueMainLoop = true
|
||||
break
|
||||
continue if continueMainLoop
|
||||
if fold = @foldForBufferRow(startBufferRow)
|
||||
placeholder = @buildFoldPlaceholder(fold)
|
||||
lineFragments.push(placeholder)
|
||||
startBufferRow = fold.end.row + 1
|
||||
startBufferColumn = 0
|
||||
currentScreenLineLength = 0
|
||||
continue
|
||||
|
||||
if wrapScreenColumn?
|
||||
line = line.splitAt(wrapScreenColumn)[0]
|
||||
|
||||
@@ -237,5 +237,5 @@ class Selection extends View
|
||||
|
||||
fold: ->
|
||||
range = @getBufferRange()
|
||||
@editor.createFold(range)
|
||||
@cursor.setBufferPosition(range.end)
|
||||
@editor.createFold(range.start.row, range.end.row)
|
||||
@cursor.setBufferPosition([range.end.row + 1, 0])
|
||||
|
||||
Reference in New Issue
Block a user