shagabutdinov / sublime-snippet-caller

Snippet system on top of default sublime snippets
Other
6 stars 3 forks source link

Newline handling issues #2

Closed VorpalBlade closed 9 years ago

VorpalBlade commented 9 years ago

There seems to be two issues with newline handling.

The first, and more serious issue is that if a variable from <eval> contains a newline and the usage of it is preceeded by an empty line in the <content>, double newlines will be inserted for each newline in the variable.

The second issue is that leading and trailing newlines in the entire are stripped. Since I use snippets to generate C/C++ header file templates and I want the file to always end in a newline, this is annoying. There is however a workaround, add a non-existing variable at the very end or very start. For example:

<content><![CDATA[
[...]
last_real_line

$nosuchvar]]></content>

Here is an example snippet that demonstrates both issues:

<snippet>
    <content><![CDATA[

test

$foo

---
$foo

xyzzy

]]></content>
    <description>TEST</description>
    <tabTrigger>TEST</tabTrigger>
    <scope>source.c++</scope>
    <eval><![CDATA[
{
    'foo': 'a\nb'
}
    ]]></eval>
</snippet>
VorpalBlade commented 9 years ago

I believe standard Sublime snippet behaviour is to strip exactly one new line at the end, I have not tested how it works at the start though.

shagabutdinov commented 9 years ago

fixed in 63bc85a43674f12084bdd4b7ae5d612382b892ea