Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support selection range in snippets #1220

Closed
jdneo opened this issue Oct 21, 2019 · 3 comments
Closed

Support selection range in snippets #1220

jdneo opened this issue Oct 21, 2019 · 3 comments

Comments

@jdneo
Copy link
Contributor

jdneo commented Oct 21, 2019

Here is a brief demonstration of the idea:
Kapture 2019-10-21 at 15 31 31

This feature might be used when the user forget to check null or something like that, and quickly wrap the code by a certain snippet.

The problem is that so far LSP does not support passing the selection information in code action param. So the server side cannot render the inserted text with the selections.

Can we first simply ignore the $TM_SELECTED_TEXT when rendering the insert text at the server side. Once the LSP supports it, we can then add them into it.

LSP related issue: microsoft/language-server-protocol#377 (comment)

@fbricon
Copy link
Contributor

fbricon commented Oct 21, 2019

Can we first simply ignore the $TM_SELECTED_TEXT

Since this is not even referenced in jdt.ls, how do you propose to do that?

@jdneo
Copy link
Contributor Author

jdneo commented Oct 21, 2019

How about:

  1. Add $TM_SELECTED_TEXT into our server side templates
  2. In beautifyDocument(String raw), detect the existence of $TM_SELECTED_TEXT and replace it with empty string.
  3. The VS Code client will replace the $TM_SELECTED_TEXT to the actual code when inserting the snippet.

But I'm not sure if the other client supports the $TM_SELECTED_TEXT as well.

@fbricon
Copy link
Contributor

fbricon commented Oct 21, 2019

Since $TM_SELECTED_TEXT is defined in the spec: https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#variables, jdt.ls can use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants