Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Indent tab stops that start from the first line of snippet properly #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/tab-stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class TabStop {
if (newRange.start.row) {
newRange.start.column += indent.length
newRange.end.column += indent.length
} else if (newRange.start.row !== newRange.end.row) {
newRange.end.column += indent.length
}
return new Insertion({
range: newRange,
Expand Down
13 changes: 13 additions & 0 deletions spec/snippets-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ third tabstop $3\
"has a transformed tab stop such that it is possible to move the cursor between the ordinary tab stop and its transformed version without an intermediate step": {
prefix: 't18',
body: '// $1\n// ${1/./=/}'
},
"has a tab stop from end of first line till the beginning of last line": {
prefix: 't19',
body: '<tag>${1:\n\t$0\n}</tag>'
}
}
});
Expand Down Expand Up @@ -583,6 +587,15 @@ third tabstop $3\
expect(editor.getCursorBufferPosition()).toEqual([3, 4]);
});

it("indents the ending tab stop if it starts from the first line (regression)", () => {
editor.setCursorScreenPosition([2, Infinity]);
editor.insertNewline();
editor.insertText('t19');
atom.commands.dispatch(editorElement, 'snippets:expand');

expect(editor.getSelectedBufferRange()).toEqual([[3, 9], [5, 4]]);
});

it("does not change the relative positioning of the tab stops when inserted multiple times", () => {
editor.setCursorScreenPosition([2, Infinity]);
editor.insertNewline();
Expand Down