mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Ensure start row is always >= 0
Previously if a file was a single line it couldn't be deleted using the delete line command because the start row would index one row back which would be -1 and therefore not be able to report a length for use in the delete range.
This commit is contained in:
parent
f241bc5d2b
commit
7278bc62c6
@ -1508,3 +1508,21 @@ describe "EditSession", ->
|
||||
expect(buffer.getLineCount()).toBe(13)
|
||||
editSession.deleteLine()
|
||||
expect(buffer.getLineCount()).toBe(4)
|
||||
|
||||
it "deletes the entire file from the bottom up", ->
|
||||
count = buffer.getLineCount()
|
||||
expect(count).toBeGreaterThan(0)
|
||||
for line in [0...count]
|
||||
editSession.getLastCursor().moveToBottom()
|
||||
editSession.deleteLine()
|
||||
expect(buffer.getLineCount()).toBe(1)
|
||||
expect(buffer.getText()).toBe('')
|
||||
|
||||
it "deletes the entire file from the top down", ->
|
||||
count = buffer.getLineCount()
|
||||
expect(count).toBeGreaterThan(0)
|
||||
for line in [0...count]
|
||||
editSession.getLastCursor().moveToTop()
|
||||
editSession.deleteLine()
|
||||
expect(buffer.getLineCount()).toBe(1)
|
||||
expect(buffer.getText()).toBe('')
|
||||
|
@ -168,7 +168,10 @@ class Buffer
|
||||
startPoint = null
|
||||
endPoint = null
|
||||
if end == @getLastRow()
|
||||
startPoint = [start - 1, @lineLengthForRow(start - 1)]
|
||||
if start > 0
|
||||
startPoint = [start - 1, @lineLengthForRow(start - 1)]
|
||||
else
|
||||
startPoint = [start, 0]
|
||||
endPoint = [end, @lineLengthForRow(end)]
|
||||
else
|
||||
startPoint = [start, 0]
|
||||
|
Loading…
Reference in New Issue
Block a user