mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-09 23:44:24 +03:00
Fix exception when trying to fold non-foldable row
This commit is contained in:
parent
43ec5193ff
commit
8d532e7780
@ -173,6 +173,26 @@ describe('TextEditor', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('.foldCurrentRow()', () => {
|
||||
it('creates a fold at the location of the last cursor', async () => {
|
||||
editor = await atom.workspace.open()
|
||||
editor.setText('\nif (x) {\n y()\n}')
|
||||
editor.setCursorBufferPosition([1, 0])
|
||||
expect(editor.getScreenLineCount()).toBe(4)
|
||||
editor.foldCurrentRow()
|
||||
expect(editor.getScreenLineCount()).toBe(3)
|
||||
})
|
||||
|
||||
it('does nothing when the current row cannot be folded', async () => {
|
||||
editor = await atom.workspace.open()
|
||||
editor.setText('var x;\nx++\nx++')
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
expect(editor.getScreenLineCount()).toBe(3)
|
||||
editor.foldCurrentRow()
|
||||
expect(editor.getScreenLineCount()).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('.foldAllAtIndentLevel(indentLevel)', () => {
|
||||
it('folds blocks of text at the given indentation level', async () => {
|
||||
editor = await atom.workspace.open('sample.js', {autoIndent: false})
|
||||
|
@ -3310,8 +3310,8 @@ class TextEditor extends Model
|
||||
# level.
|
||||
foldCurrentRow: ->
|
||||
{row} = @getCursorBufferPosition()
|
||||
range = @tokenizedBuffer.getFoldableRangeContainingPoint(Point(row, Infinity))
|
||||
@displayLayer.foldBufferRange(range)
|
||||
if range = @tokenizedBuffer.getFoldableRangeContainingPoint(Point(row, Infinity))
|
||||
@displayLayer.foldBufferRange(range)
|
||||
|
||||
# Essential: Unfold the most recent cursor's row by one level.
|
||||
unfoldCurrentRow: ->
|
||||
|
Loading…
Reference in New Issue
Block a user