hsnips
hsnips copied to clipboard
Expanding snippets inside snippets deletes tabstops
Possibly very related to #157.
When expanding a snippet inside another snippet, all tabstops of the former snippet are deleted. An example:
snippet OOO "Omega" iA
\Omega
endsnippet
snippet II "\int" i
\\int_{$1}${2:f}~d${3:\\mu}
endsnippet
If I write "OOO" inside tabstop $1 of "\int", the snipet "Omega" is expanded correctly, but the tabstops $2 and $3 of "\int" disappear.
This doesn't happen with "native" vscode snippets.
Additional note, downgrading VS Code to the December 2023 version fixed this bug for me.
I am having the same issue, but downgrading did fix it for me.
Anyone find another fix to this? I am using linux (arch) and have a hard time downgrading as I got vscode from the AUR
Any update? I originally downgraded to December 2023 but thought I'd retry and this is still an issue. I haven't been able to figure out what part of the VSCode update affected this to think of a workaround. Any ideas for what it may be?
Nothing new. Still does not work. Have you @gwesley96 tried any other versions later than the December one? Would be ideal to see which exact version causes issues.
@Oskar-Idland, do you mean the commit or the release? I can try and figure out the latter.
Yes i meant the latest vscode release where expansions works as intended. Hopefully it helps resolve the issue to narrow it down
Ok, tabstops still work in 1.85.2
but not 1.86.0
.
I tried seeing the difference on the 1.86 commit, but could not see anything that made sense. Anyone able to try and debug this?
Same issue here
Experimented more in v.1.87.2 and found the following:
- LaTeX Utilities's snippets and the ones built into vscode still works while nested. Only hsnips fails.
- I also noticed that you must have the hsnips by OrangeX4 (https://github.com/OrangeX4/hsnips) to be able to open the snippet directory or files or be able to activate any snippets at all. If I only had draivin's (this) version of hsnips I could not even open the snippet file as I got the following error:
I'm still coming up with nothing. I've looked through all the details and couldn't find anything that on the surface would affect hsnips/tabstops. Has anyone else found anything yet?
Anyone know the maintainers (@draivin @mfederczuk) of the extension is on it?
Anyone know the maintainers (@draivin @mfederczuk) of the extension is on it?
Just FYI I'm not a maintainer here.
I've only contributed some code once.
For any Arch Linux users reading this, just download the tar ball from 1.85 (other distros has their versions there as well), extract to some directory of choice (I chose ~/VSCode_Old
), then just make a symlink from /usr/bin/code
to the executable at VSCode-linux-x64/bin/code
where ever you extracted it. I renamed the newest binary to code_new
just to have it somewhere:
[oskar@archlinux] /usr/bin $ lsd -1 | grep ^code
code ⇒ /home/oskar/VSCode_Old/VSCode-linux-x64/bin/code
code_new
Everything else (settings, snippets etc) remained the same.
Is anybody able to make the above solution work for MacOS?
If you press the link I posted above, you will see the download link for Mac as well as Windows and Linux. This is much simpler for you guys
Oh okay, it sounds like you merely downgraded your Visual Studio Code (I guess your point of the comment was to make it work for linux). Yes, that's what I have been doing for the time being.
Hope this gets fixed. Can't use the python extension (and probably many others) on lower than v1.86
Anyone have actual knowledge about the project and it's structure or Typescript? I have neither, but know programming and would love to help sort this out, but it is hard to tell what is wrong, without knowledge of the project
Could it be possible that this is a vscode issue and raising the issue there would get it fixed or maybe some pointers towards solving the issue?
Testing with the regular user snippets, they preserve tabstops if nested
I found where the problem lies. In VSCode 1.86.0, at line 538 of the file src/vs/workbench/api/browser/mainThreadEditor.ts,
snippetController.insert(template, {
overwriteBefore: 0, overwriteAfter: 0,
undoStopBefore: opts.undoStopBefore, undoStopAfter: opts.undoStopAfter,
clipboardText
});
has been replaced with
const edits: ISnippetEdit[] = ranges.map(range => ({ range: Range.lift(range), template }));
snippetController.apply(edits, {
overwriteBefore: 0, overwriteAfter: 0,
undoStopBefore: opts.undoStopBefore, undoStopAfter: opts.undoStopAfter,
clipboardText
});
Reverting this change should allow the compiled vscode to function properly with hypersnips.
Great job!! How did you find it? There were soooo many files and changes I gave up looking after a while.
I think the next step should be to find what part of hyprsnips interact with this feature, instead of patching vscode. Nested snippets still work with other snippet programs, so it must be possible.
Searching through the files, I see no mention of this "snippetController". Do you know in what context it is used ?
@yiktllw Thank you very much for finding the error. Can you detail the process as to how we can achieve the same? I tried cloning the repository and making the change, but I keep running in errors trying to compile the repository.
@yiktllw Thank you very much for finding the error. Can you detail the process as to how we can achieve the same? I tried cloning the repository and making the change, but I keep running in errors trying to compile the repository.
I tried the latest source code of VSCode(1.90.0). After modifying
const edits: ISnippetEdit[] = ranges.map(range => ({ range: Range.lift(range), template }));
snippetController.apply(edits, {
overwriteBefore: 0, overwriteAfter: 0,
undoStopBefore: opts.undoStopBefore, undoStopAfter: opts.undoStopAfter,
clipboardText
});
to
snippetController.insert(template, {
overwriteBefore: 0, overwriteAfter: 0,
undoStopBefore: opts.undoStopBefore, undoStopAfter: opts.undoStopAfter,
clipboardText
});
I also removed
import { ISnippetEdit } from 'vs/editor/contrib/snippet/browser/snippetSession';
from the beginning of the file. Following these changes, I was able to compile the code successfully.
Searching through the files, I see no mention of this "snippetController". Do you know in what context it is used ?
It was mentioned at line 530 of the file:
// import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
const snippetController = SnippetController2.get(this._codeEditor);
I'm not sure about the specific usage of snippetController
either.
yeah I tried looking through any mentioned of everything mentioned above in both hsnips and in the hscope repo. I found nothing.
@yiktllw Okay, I am able to change the line inside the src folder and I was also able to run the yarn and yarn watch commands on the terminal. However, I am not sure how to actually produce the application of vscode. Can you provide some instructions for that?