mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Correctly place tab stop anchor ranges in snippets with blank lines
This commit is contained in:
parent
47ca7f81c1
commit
fa8ca1193f
@ -66,6 +66,15 @@ describe "Snippets extension", ->
|
||||
${2:placeholder ending second line}
|
||||
"""
|
||||
|
||||
"contains empty lines":
|
||||
prefix: "t7"
|
||||
body: """
|
||||
first line $1
|
||||
|
||||
|
||||
fourth line after blanks $2
|
||||
"""
|
||||
|
||||
describe "when the letters preceding the cursor trigger a snippet", ->
|
||||
describe "when the snippet contains no tab stops", ->
|
||||
it "replaces the prefix with the snippet text and places the cursor at its end", ->
|
||||
@ -140,6 +149,14 @@ describe "Snippets extension", ->
|
||||
editor.trigger keydownEvent('tab', target: editor[0])
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[0, 5], [0, 10]]
|
||||
|
||||
describe "when tab stops are separated by blank lines", ->
|
||||
it "correctly places the tab stops (regression)", ->
|
||||
buffer.setText('')
|
||||
editor.insertText 't7'
|
||||
editor.trigger 'snippets:expand'
|
||||
editor.trigger 'snippets:next-tab-stop'
|
||||
expect(editSession.getCursorBufferPosition()).toEqual [3, 25]
|
||||
|
||||
describe "when the cursor is moved beyond the bounds of a tab stop", ->
|
||||
it "terminates the snippet", ->
|
||||
editor.setCursorScreenPosition([2, 0])
|
||||
|
@ -30,7 +30,7 @@ class Snippet
|
||||
bodyText.push(segment)
|
||||
segmentLines = segment.split('\n')
|
||||
column += segmentLines.shift().length
|
||||
while nextLine = segmentLines.shift()
|
||||
while (nextLine = segmentLines.shift())?
|
||||
row += 1
|
||||
column = nextLine.length
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user