mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Only add newline when insert row exceeds last row
Previously if the line before a trailing newline was duplicated an extra newline would inserted with the duplicated line.
This commit is contained in:
parent
d27bbee37d
commit
dedde7b222
@ -2680,6 +2680,18 @@ describe "Editor", ->
|
|||||||
expect(buffer.lineForRow(15)).toBeUndefined()
|
expect(buffer.lineForRow(15)).toBeUndefined()
|
||||||
expect(editor.getCursorBufferPosition()).toEqual [14, 0]
|
expect(editor.getCursorBufferPosition()).toEqual [14, 0]
|
||||||
|
|
||||||
|
describe "when the cursor is on the second to last line and the last line only a newline", ->
|
||||||
|
it "duplicates the current line below and moves the cursor down one row", ->
|
||||||
|
editor.moveCursorToBottom()
|
||||||
|
editor.insertNewline()
|
||||||
|
editor.setCursorBufferPosition([12])
|
||||||
|
editor.trigger 'editor:duplicate-line'
|
||||||
|
expect(buffer.lineForRow(12)).toBe '};'
|
||||||
|
expect(buffer.lineForRow(13)).toBe '};'
|
||||||
|
expect(buffer.lineForRow(14)).toBe ''
|
||||||
|
expect(buffer.lineForRow(15)).toBeUndefined()
|
||||||
|
expect(editor.getCursorBufferPosition()).toEqual [13, 0]
|
||||||
|
|
||||||
describe ".moveEditSessionToIndex(fromIndex, toIndex)", ->
|
describe ".moveEditSessionToIndex(fromIndex, toIndex)", ->
|
||||||
describe "when the edit session moves to a later index", ->
|
describe "when the edit session moves to a later index", ->
|
||||||
it "updates the edit session order", ->
|
it "updates the edit session order", ->
|
||||||
|
@ -421,7 +421,7 @@ class EditSession
|
|||||||
bufferRange = new Range([cursorPosition.row], [cursorPosition.row + 1])
|
bufferRange = new Range([cursorPosition.row], [cursorPosition.row + 1])
|
||||||
|
|
||||||
insertPosition = new Point(bufferRange.end.row)
|
insertPosition = new Point(bufferRange.end.row)
|
||||||
if insertPosition.row >= @buffer.getLastRow()
|
if insertPosition.row > @buffer.getLastRow()
|
||||||
@unfoldCurrentRow() if cursorRowFolded
|
@unfoldCurrentRow() if cursorRowFolded
|
||||||
@buffer.append("\n#{@getTextInBufferRange(bufferRange)}")
|
@buffer.append("\n#{@getTextInBufferRange(bufferRange)}")
|
||||||
@foldCurrentRow() if cursorRowFolded
|
@foldCurrentRow() if cursorRowFolded
|
||||||
|
Loading…
Reference in New Issue
Block a user