hsnips icon indicating copy to clipboard operation
hsnips copied to clipboard

placeholder disappears when using the automatic snippet

Open cht33 opened this issue 3 years ago • 14 comments

Hello, I've got a problem that behaves kind of like https://github.com/draivin/hsnips/issues/38, but I don't know how to fix it. I have this two snippets

snippet lim "auto limit" w
\lim\limits_{${1:n} \to ${2:\infty}} $0
endsnippet

`(?<=\b|\d+)(?<!\\)(tau)` "greek" wA
\\``rv = m[1]``$0
endsnippet

When I'm in the lim snippet, and then I type in tau, it will change into \tau but make the placeholer disappear. Snipaste_2021-09-28_22-08-25 Snipaste_2021-09-28_22-08-44

Could anyone gives some tips about that problem?

cht33 avatar Sep 28 '21 14:09 cht33

I think that your snippet should be:

snippet lim "auto limit" w
\lim\limits_{${1:n} \to ${2:\infty}} $0
endsnippet

snippet `(?<=\b|\d+)(?<!\\)(tau)` "greek" wA
\\``rv = m[1]``$0
endsnippet

but I think everything is okay...

1111

Can you provide more information? or...🤔

yfzhao20 avatar Sep 28 '21 16:09 yfzhao20

Can you provide more information? or...🤔

@yfzhao20 Hello! Actually I'm working on my math homework, one is with latex in wsl2-Ubuntu20.04 and another one is with markdown in Win10. I've fully tested on both systems and found something really strange:

  1. When I'm using latex in WSL2, hypersnips works quite well, like that: latex

  2. However when I'm using markdown in Win10, the strange behaviour described above happened: markdown

Maybe the cause is the difference between these two languages? I've no idea about how to fix this problem..

cht33 avatar Sep 29 '21 03:09 cht33

I've tested this problem again in Win10 (at least in WSL2 everything is fine). This problem happens only when the auto completion is triggered, if I use tab to complete there is no problem.

I doubt that there maybe some conflicts between hypersnips and vim.

  1. I tested latex in Win10 and the problem still exists, so I think the language doesn't matter.
  2. I disabled most of my extentions, and the problem was gone.
  3. Finally I found that when I enabled the vim extention, the problem came again!
  4. However, in the remote-wsl mode, I enabled all my extentions and there was no such problem.

The testing procedure is as follows: markdown_latex

cht33 avatar Sep 29 '21 07:09 cht33

Sorry but I don't use "vim" as editor. So maybe I have tried my best 😂 Maybe you can check your snippets in "Vim"?

yfzhao20 avatar Sep 29 '21 07:09 yfzhao20

Sorry but I don't use "vim" as editor. So maybe I have tried my best 😂 Maybe you can check your snippets in "Vim"?

I delete all my vscode-vim configuration in the settings.json, but the problem still exists... So there must be some conflicts between these two extensions. Actually I'm trying to use vscode to write latex/markdown, so I choose the vscode-vim + hypersnips extensions in substitution for vim + UltiSnips. However there are quite a lot of difference between hypersnips and UltiSnips, maybe the author knows how to fix this problem. Anyway, thanks a lot! @yfzhao20

cht33 avatar Sep 29 '21 08:09 cht33

I also use VScodeVim+hypersnips, and I got the same problem 😂

changxvv avatar Sep 30 '21 06:09 changxvv

I also have the same problem. But it will be fine trying the plug named VSCode Neovim to replace the Vim plug.

yunus-sun avatar Sep 30 '21 09:09 yunus-sun

Same here with simple snippets:

snippet ab "Ab" A
a $1 b
endsnippet

snippet cc "Cc" A
cc
endsnippet

Typing abcc lock me at | in a cc| b and I can't use tab to go to the end (a cc b|) once the cc snippet expanded.

Using Vscode + Vim + Hsnips.

gruvw avatar Nov 25 '21 15:11 gruvw

So, I looked into it, the placeholder disappearance is caused by a workaround we are currently using to get around a VsCodeVim issue.

History time:

  • We started using the workaround to get around this issue https://github.com/draivin/hsnips/issues/28.
  • Supposedly, the related issue in VSCodeVim was fixed here https://github.com/VSCodeVim/Vim/issues/5240.
  • I'm not sure if it was never properly fixed, or if a regression happened, but it seems that the issue still exists (see https://github.com/VSCodeVim/Vim/issues/7068), so while that issue is still open, we can't remove the workaround and fix this bug.

draivin avatar Dec 02 '21 23:12 draivin

This is exactly my problem with hsnips. This is quite annoying tbh, and this causes so much headache for my workload. But at this moment, this is still the best snippets extension I can find... hope this can be fixed in a near future.

sleepymalc avatar Feb 18 '22 04:02 sleepymalc

I've noticed that if we use a $2 tabstop instead of a $0 tabstop, tabs continue to work even with expansions. The only issue is that it's difficult to "end the snippet" (see https://github.com/draivin/hsnips/issues/1) which results in continuous highlighting of text after the tab (see https://github.com/draivin/hsnips/issues/106) and requiring two "esc" keys to go into vim normal mode.

snippet mk "inline math" wA
\$$1\$ $2
endsnippet

Is there a way to end the snippet easily if we use a $2 tabstop?

su-stephen avatar Mar 30 '22 11:03 su-stephen

I would like to bump this issue, they started disappearing for me starting last update (v0.2.9), exactly as described above. I am not using Vim or anything similar, and su-stephen's $2 workaround does not work for me either.

Edit: I have just tried downgrading to v0.2.8, and looks like they're not working on earlier versions anymore either... might be a VSCode thing.

XRay71 avatar Feb 02 '24 18:02 XRay71

Same here. With no vim extension still I have the issue of disappearing tab-stobs in nested snips and the $2 hack does not solve this either. Also on v0.2.9.

dromeldar avatar Apr 17 '24 18:04 dromeldar

I also have the problem without the vim extension. Even without all extensions except hyperscopes and hypersnips the problem is still there.

FlynnFehre avatar Jun 30 '24 11:06 FlynnFehre