Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Placeholders are incorrectly replaced with noexpandtab when on indented lines #143

Closed
fish-face opened this Issue Jan 21, 2014 · 1 comment

Comments

Projects
None yet
2 participants

I noticed this issue with the following latex snippet:

snippet begin
    \begin{${1:env}}
        ${0}
    \end{$1}

When I use this on an indented line containing just "begin", while using noexpandtab and a tabstop of 4, I get the following, as expected:

    \begin{env}

    \end{env}

However, if I then start typing "d" to replace "env" I get the following:

    \begin{d}

    \end{envd

And typing more continues to add things to the end of the last line. This is definitely a problem with indentation as changing the value of tabstop changes where the substitution happens: in particular if tabstop is 1 then it is correct. Hence somewhere in snipmate, columns are being stored/calculated as screen columns, instead of character columns. I think the following fixes the issue:

diff --git a/autoload/snipMate.vim b/autoload/snipMate.vim
index 1930499..35928d4 100644
--- a/autoload/snipMate.vim
+++ b/autoload/snipMate.vim
@@ -79,7 +79,7 @@ fun! snipMate#expandSnip(snip, col)
        endif

        " Insert snippet with proper indentation
-       let indent = indent(lnum) + 1
+       let indent = match(line, '\S\|$') + 1
        call setline(lnum, line . snipLines[0])
        call append(lnum, map(snipLines[1:], "empty(v:val) ? v:val : '" . strpart(line, 0, indent - 1) . "' . v:val"))

(The issue being that indent() returns the indentation of the current line in screen columns)

fish-face added a commit to fish-face/vim-snipmate that referenced this issue Jan 21, 2014

ajzafar added a commit that referenced this issue Jan 22, 2014

Count indents in bytes rather than columns
Fixes issue #143 and merges pull request #144
Collaborator

ajzafar commented Jan 22, 2014

Thanks! Merged.

@ajzafar ajzafar closed this Jan 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment