sleepymalc / VSCode-LaTeX-Inkscape

✍️ A way to integrate LaTeX, VS Code, and Inkscape in macOS
https://pbb.wtf/posts/VSCode-LaTeX-Inkscape/
MIT License
364 stars 24 forks source link

Context Not Working for Hsnips #17

Closed ColtWhitley closed 1 year ago

ColtWhitley commented 1 year ago

Hi I am trying to get this system up and working for my own note taking, but for some reason the code snippets work regardless of the context I am writing in. This means that I cannot take notes in English without my words becoming replaced by expressions that are quite useful for equations but not explanations. If anyone knows why the context is no longer filtering please let me know!

Here is the code I have tried to fix the context issues:

global
function math(context) {
    return context.scopes.some(s => s.startsWith("meta.math"));
}
endglobal
global
function math(context) {
    return  context.scopes.findLastIndex(s => s.startsWith("meta.math")) > context.scopes.findLastIndex(s => s.startsWith("comment") || s.startsWith("meta.text.normal.tex"));
}
endglobal
global
function math(context) {
    return context.scopes.some(s => s.startsWith("math"));
}
endglobal
sleepymalc commented 1 year ago

The current scope of the location of your cursor can be seen by inspecting Developer: Inspect Editor Tokens and Scopes (by shift+cmd+p and searching for this). Please provide more info about in what scenario the snippets are falsely triggered and what's the corresponding scope.

For example, you should see the following when you're in the math environment: image

Also, it helps to inspect the extension log via Developer: Open Extension Logs Folder, to see whether there are any weird errors.

ColtWhitley commented 1 year ago

The snippets are working even when the context doesn't contain meta.math

Screen Shot 2023-01-11 at 12 25 37 PM

In the extension Logs folder the only thing I see is this but I don't know what it means: 2023-01-11 12:23:35.867 [error] TypeError: Cannot read properties of undefined (reading 'range') at HSnippetInstance.update (/Users/coltwhitley/.vscode/extensions/draivin.hsnips-0.2.8/src/hsnippetInstance.ts:213:19)

sleepymalc commented 1 year ago

Yes, this is the only issue Hypersnips currently has and remains unresolved. See here. A quick fix might be simply closing the current tab and reopening it again: this usually works, and I suggest you simply put one more tab (some random file or just latex.hsnips for a quick change), so whenever you encounter, when closing the tab, windows will not be re-adjust (might sound cryptic but you'll get the idea when you try).

ColtWhitley commented 1 year ago

Dam that sucks, but thank you! it was definitely an intermittent issue so I was really struggling to resolve :) Have a good day