leanprover / vscode-lean

Extension for VS Code that provides support for the older Lean 3 language. Succeeded by vscode-lean4 ('lean4' in the extensions menu) for the Lean 4 language.
Apache License 2.0
116 stars 49 forks source link

Proposal for an API based "Suggestions" detail in infoview #312

Closed timlacroix closed 2 years ago

timlacroix commented 2 years ago

As described in the title. Some missing things on which I'd like help :

gebner commented 2 years ago

debouncing queries to the API when editing the "prefix" field. (If we want to keep this field. Not sure it's super valuable)

You might want to check out the delayedThrottle function. https://github.com/leanprover/vscode-lean/blob/master/infoview/info.tsx#L66-L82

I think the prefix field is actually a nice idea.

gebner commented 2 years ago

clicking -> paste into editor. I imagine I should do something similar to

The pasteTacticSuggestion stuff replaces the current tactic, which is not what we want here.

What we actually want here is to insert a tactic before the current one. But doing this properly is pretty hard in Lean 3, so I would suggest to just insert the suggestion on the line above. This should do the trick:

    post({ command: 'insert_text', text: `\n${suggestion}\n`, insert_type: 'relative'});
gebner commented 2 years ago

The mechanics are great now. I think it's good enough to try out on real users now.