You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are steps to reproduce the issue. I won't provide a minimal .vimrc here because I think it will be clear, but please let me know if it would help and I can do so.
Paste the snippet above in some empty .py file, e.g. with CTRL+J in the suggested bindings
Navigate to the third placeholder e.g. with TAB in the default bindings
Attempt to type X, X[, X[0, X[0, (in sequence). The idea is that I'm trying to index a row of a matrix X.
After typing the , (comma), observe that vsnip exits the snippet context. It is no longer possible to navigate to other placeholders, edit them, etc.
After poking around in the source for a while, I seemed to pinpoint at least roughly where the issue is:
The call to Diff.compute at https://github.com/hrsh7th/vim-vsnip/blob/master/autoload/vsnip/session.vim#L227 behaves somewhat oddly in this setting. The relevant portion of the string being typed, right before the comma is added, looks like X[0,, because there is a comma in the snippet following the third placeholder $3. After the comma is typed, the new buffer content is X[0,,. Here, Diff.compute will return the index of the second comma, because what it does is look for the first character between the two strings that differs! On the other hand, the character that was actually inserted is the first comma.
This will then run into an issue when self.snippet.follow is called later in this same context. It seems that what ends up triggering a call to vsnip#deactivate is the is_followable call at https://github.com/hrsh7th/vim-vsnip/blob/master/autoload/vsnip/snippet.vim#L98. I wasn't able to figure out exactly what the issue is here, due to some confusion about what is going on with the traverse function.
I wonder if you can help diagnose the issue here and how it might be fixed. (Sorry, I had hoped to find a solution just by poking around in the code, but feel like I have run into a dead end.) In the meantime, it is possible for me to work around this issue by using the arrows to move around while inputting text and avoiding typing the comma, e.g. the sequence X, X[, X[0, X[0:, left arrow, X[0,:. But this seems like an undesirable interaction and hopefully it can be fixed.
The text was updated successfully, but these errors were encountered:
Sorry, now that I have actually written it up and thought about it more, I think I see this is the same issue as #254. I'll work around it following your suggestion in the help file for now.
Hi,
I ran into the following issue when working with the following python snippet (some simple plotting code):
Here are steps to reproduce the issue. I won't provide a minimal
.vimrc
here because I think it will be clear, but please let me know if it would help and I can do so..py
file, e.g. withCTRL+J
in the suggested bindingsTAB
in the default bindingsX
,X[
,X[0
,X[0,
(in sequence). The idea is that I'm trying to index a row of a matrixX
.,
(comma), observe that vsnip exits the snippet context. It is no longer possible to navigate to other placeholders, edit them, etc.After poking around in the source for a while, I seemed to pinpoint at least roughly where the issue is:
Diff.compute
at https://github.com/hrsh7th/vim-vsnip/blob/master/autoload/vsnip/session.vim#L227 behaves somewhat oddly in this setting. The relevant portion of the string being typed, right before the comma is added, looks likeX[0,
, because there is a comma in the snippet following the third placeholder$3
. After the comma is typed, the new buffer content isX[0,,
. Here,Diff.compute
will return the index of the second comma, because what it does is look for the first character between the two strings that differs! On the other hand, the character that was actually inserted is the first comma.self.snippet.follow
is called later in this same context. It seems that what ends up triggering a call tovsnip#deactivate
is theis_followable
call at https://github.com/hrsh7th/vim-vsnip/blob/master/autoload/vsnip/snippet.vim#L98. I wasn't able to figure out exactly what the issue is here, due to some confusion about what is going on with thetraverse
function.I wonder if you can help diagnose the issue here and how it might be fixed. (Sorry, I had hoped to find a solution just by poking around in the code, but feel like I have run into a dead end.) In the meantime, it is possible for me to work around this issue by using the arrows to move around while inputting text and avoiding typing the comma, e.g. the sequence
X
,X[
,X[0
,X[0:
,left arrow
,X[0,:
. But this seems like an undesirable interaction and hopefully it can be fixed.The text was updated successfully, but these errors were encountered: