Closed anonymousALLDAY closed 1 year ago
The global scope is evaluated only once, when parsing the snippets, and so this is not a bug. If you intend to get the current active window, you should probably have that code inside a function defined on the global scope, and evaluate the function by using context
during the snippet expansion.
if you do this, the variable
editor
refers to .hsnips file, not current file.you can reproduce this by
create a snippet that
Before trying the snippet in a different file, put the cursor in a different position from when you're in .hsnips file.
test the snippet, expand it.
then you can easily check that the return value of position is of the cursor of .hsnips file, not the file you are currently editing.
This might not be a bug, but it would be more useful for
activeTextEditor
to target current document even though it was declared in global block, as callingactiveTextEditor
in each snippet block is tedious and inefficient.