VSCode snippets (Hypersnips) tab stops in nested use of snippets - visual-studio-code

I am using VSCode Hypersnips (based off of Vi's https://github.com/SirVer/ultisnips), following this guide . See also Create-Snippets-For-Ultisnips.
Consider the following example: I have a snippet
snippet fm "inline Math" wA
\(${1}\) $0
end snippet
and another snippet
snippet ( "parenthesis" wiA
($1) $0
end snippet
If I were to type fm, then that would produce \(|\) |, where the first | is where my cursor is, and the second | is where my cursor would be if I pressed <Tab>. Now, when I type fm ( hi <Tab> that produces \((hi) |\) as expected, but when I press <Tab> again (hoping to use the $0 tab stop of the fm snippet), I don't get outside the right \) like I want, and instead a tab character (i.e. 2 spaces) are placed where the cursor is.
I am wondering if I can nest snippets like this, and still use the tab stops of the outer snippet once I exit the inner snippet.
I assume the same issue occurs if I use native VSCode snippets.
StackOverflow informs me that a similar question has been asked: Atom - Nested snippets with tab stops error, but not about VSCode's snippets.

It seems this is known issue: https://github.com/draivin/hsnips/issues/78. This is a summary of the issue from Dec. 2 2021:
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 Trigger A leaves me in visual mode, I want it to leave me in insert
mode instead #28.
Supposedly, the related issue in VSCodeVim was fixed
here Snippet is not working Properly VSCodeVim/Vim#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 Unexpectedly entered visual
mode in snippet VSCodeVim/Vim#7068), so while that issue is still
open, we can't remove the workaround and fix this bug.
For now, https://github.com/draivin/hsnips/issues/126 offers what I think is the best solution, namely using VSCode Neovim.

Related

Visual studio 2022, Press '(' on selected text not working (as expected)

I don't know how to describe this behaivor:
Press ( key on selected text in vs2022, what i want is to replace the whole selection with (, but it does not, even worse, what it does is to add another ) to the end of the selection, this is really annoying and happened many times. i tried to find options in Tools/Options, twice, and nothing found to disable it.
(actualy, it happens to all marching symbols like "(<{, so i guess it's something to do with the brace marching thing.)
Please help, thank you.

Vscode: Hypersnips excention sometimes duplicates cursor

I have the following snippet in the hypersnips extension (in vscode)
snippet txt "text in math" imA
\text{$1}
endsnippet
Usually, it works fine with me typing txt and it automatically sends me to
However, sometimes when using a snippet I get the following
After this occurs, if I delete that and try again, I get
This "bug" (?) occurs 10-20 per cent of the time and it is very annoying. Moreover, it is not unique to a specific snippet.
I have tried changing the version of vscode and of the extension but nothing has seemed to work.
Any help will be greatly appreciated.
EDIT: Screenshot to address rioV8's comment
I think that it is the bug of VSCode. When you overlap placeholders more than (about) 18 times, it occurs.
Just because HyperSnips adds too many placeholders, you noticed the bug.
Test: use VSCode keybindings to add snippet (without extensions).
ctrl+M inserts $|$ | .
Click here to view the result
However I don't know why it occurs and how to solve the problem. Sorry for that.

Why VS Code showing suggestion even if they are not related to words and apparently also applying them after entering shift + 9?

I am trying to learn gulp and so I am using rename() method but VS Code is showing those unrelated suggestion as shown in the image and as I am typing shift + 9 to make brackets for the method, the first suggestion is getting applied instead of rename() and it is changing to requestAnimationFrame(). Why this behavior is happening and how can I fix this ?
https://i.stack.imgur.com/K2qdt.jpg
( is treated as commit character for method suggestion. Typing it will accept the current suggestion.
Press escape to cancel out of the current suggestion before pressing ( or disable commit characters entirely by setting "editor.acceptSuggestionOnCommitCharacter": false

Dr Racket fails when trying to create ]

I'm playing around a bit with DrRacket in the BSL language.
When I'm trying to create a comment like so:
;; Hi(10, 50]
The program fails in the moment when typing the ]. I can only end it via TaskManager. It uses 13 CPU in the TM.
Has anyone of you a solution for that? or is it simply not to use ].
Thank you
This is some bug that was reported several times recently, and there's no fix, yet. It's probably a result of some non-english keyboard layout (which was the case in these reports). Hopefully it will get fixed soon...
UPDATE: The bug was fixed for the next release, but in the meanwhile Matthew posted some instructions on how to do a temporary fix -- repeated here for reference:
We have tracked down a problem that occurs when the AltGr key is needed
to type ].
DrRacket gets stuck due to a bad implementation of an operation that is
intended to be bound to Alt-]. For most of you, though, the problem is
that you didn't want the Alt-] keybinding at all; you're just trying to
type ], and it's misinterpreted as Alt-].
You can work around the problem by placing the five lines at the end of
this message in a file, and then selecting the file via the
Edit -> Keybindings -> Add User-defined Keybindings...
menu item in DrRacket. Typing ] should work immediately after, and
typing [ will also give you just [ (instead of [ and ]).
Beware that after you select the file, it will be difficult to unselect
it. It turns out the the menu item to un-select a keybindings file is
also buggy! Your best bet is to put the file in a place that it can
stay. (You can still edit the file and restart DrRacket if you just
want to drop the bindings.)

Oddball issue arising with use of TextWrangler to edit Python 2.7 script which tests multithreading and Queue modules

I'm writing a script in Python 2.7 exploring the use of the multithreading and Queue modules. the script just defines two functions, one of which will be started in a thread instance to fill a Queue, and a second one which will be started in a second thread instance to pull something off the Queue. However, I cannot even get this script to execute, as it chokes on one of the function definitions even before it executes. The code snippet with the problem is:
def listenThread(counter):
while queue.empty() != True:
try:
outcome = queue.get()
print outcome
counter -=1
print counter
except:
return 'queue.get() command loop failing.'
The error message I am getting is:
$ python threading-and-queue-test.py
File "threading-and-queue-test.py", line 34
except:
^
IndentationError: unindent does not match any outer indentation level
$
I've searched SO and checked the docs for correct formation of the try-except construct, and it seems OK. I had earlier versions of the code (without the try-except ) working, so I am getting suspicious about the text editor, TextWrangler v4.0.1.
Can anyone suggest a debug approach or code correction?
Thanks!
Red
As you have already suspected, it is most likely an indentation error. Your text editor is probably mixing the use of tabs and spaces. Replace all tabs with spaces (or vice versa though the standard in python is 4 spaces) and you should see the error disappear.
For those who find this question later like I did it's easy to fix TextWrangler's settings and stop this issue altogether; Go to "Preferences" -> "Editor Defaults" -> "Auto-expand tabs" then set tabs to 4 spaces. Restart TextWrangler for changes to take affect. For existing documents that continue giving you a problem read this.