talonhub / community

Voice command set for Talon, community-supported.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VSCode Python snippets don't work

pokey opened this issue · comments

"snip show" works (for a Python file) and shows the language appropriate snippets. But "snip if else" does not work. I debug by print (in vscode.py):

  def snippet_insert(text: str):
        """Inserts a snippet"""
        actions.user.vscode("editor.action.insertSnippet")
        actions.insert(text)
        actions.key("enter")
        print(f"snippet_insert {text}")

And indeed I see "if/else" printed as expected in the log consul. The vscode window also flickers at the top, that's all. Now, if I do "snip hunt", then a pop-up textbox occurs with the text "select snippet" but there are no snippets to choose amongst. So it appears as if there are two snippet systems: one of vscode and one of Talon - but they don't know about each other.

Originally posted by @fusentasticus in #1069 (comment)

Hmm. I'm not sure which snippets those are supposed to be referring to. Looks like the Talon list is defined here:

https://github.com/knausj85/knausj_talon/blob/4601a8ba431784a9c194189cc5693f577b19043c/apps/vscode/snippets/python_snippets.py#L11-L24

@knausj85 were these snippet names supposed to refer to some standard list of snippets, or is the user expected to define them

It looks like these refer to the default snippets that were removed from the Python extension a couple of years ago: https://devblogs.microsoft.com/python/python-in-visual-studio-code-january-2021-release/#other-changes-and-enhancements

@auscompgeek is correct.

I actually use the commented out functionality that parses the user-defined snippets.

This is probably a good excuse to revisit the snippet support in vscode if there's a better way to do things. The snippet parsing + functionality for creating speakable names might be far enough along to be a sensible default.