Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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

@fish-face
Copy link

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 pushed a commit that referenced this issue Jan 22, 2014
Fixes issue #143 and merges pull request #144
@ajzafar
Copy link
Collaborator

ajzafar commented Jan 22, 2014

Thanks! Merged.

@ajzafar ajzafar closed this as completed Jan 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants