On Tue, 6 Jul 2010, Tony Mechelynck wrote:

> Forward to list.
> 
> -------- Original Message --------
> Subject: Re: synstack() in insert mode
> Date: Tue, 6 Jul 2010 05:59:18 +0100
> From: Marcin Szamotulski <[email protected]>
> To: Tony Mechelynck <[email protected]>
> 
> On 04:09 Tue 06 Jul     , Tony Mechelynck wrote:
> > On 06/07/10 02:13, Marcin Szamotulski wrote:
> > >
> > > Sorry for not being precise, this doesn't give an error, but 
> > > g:synstack variable should be a list while if I do ':echo 
> > > g:synstack' I get '0' not '[]'.
> > >
> > > In a script I'm getting error because I then process with 
> > > g:synstack as a list.
> > >
> > > Best regards,
> > > Marcin
> > 
> > Well, I get the value [] in g:synstack.
> > 
> > Also, please remember that bottom-posting is preferred on this list, 
> > as mentioned until two and a half hours ago at the very bottom of 
> > every post.
> > 
> 
> In both gentoo distributed version of vim and fresh install (using svn)
> I get an error while in empty line, in non empty line things works fine.
> 

Using Tony's example autocmd:
:set cmdheight=2
:aug testing
:au!
:au CursorMovedI * echo synstack(line('.'),col('.'))
:aug END
I get an empty value (not []) when the cursor is at the end of the line.

E.g. with ft=sql, enter insert mode and use the arrow keys to move.  
Cursor position marked with '^' below, and the output of the autocmd.  
There's no trailing space on the line.

select * from
      ^ - []
select * from
            ^ - [108]
select * from
             ^ - blank

Changing the autocmd to need a list, I get 'List required' errors:

e.g.:
:aug testing
:au!
:au CursorMovedI * let l=synstack(line('.'),col('.')) | for x in l | echo "," l 
| endfor
:aug END

For the OP: The workaround is probably to change whatever is setting g:synstack 
to check for an index beyond the end of the line:

" off the cuff -- probably wrong for multibyte encodings...
if col('.') > strlen(getline('.'))
   let g:synstack = []
else
   let g:synstack = synstack(line('.'),col('.'))
endif

-- 
Best,
Ben

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to