-
Notifications
You must be signed in to change notification settings - Fork 919
Add snippet text edit specification #1892
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
Conversation
|
Can you also check out my questions in #724 (comment) and potentially address in the spec? |
|
@rchl I commented here: #724 (comment) |
|
To make snippets with multiple tab stops (#724 (comment)) work properly, clients likely need to use built-in editor functionality to insert the text as a snippet. This might imply that the editor automatically re-indents inserted text which contains multiple lines; for example it seems to be the case in VSCode (#724 (comment)), and it also happens in Sublime Text. A similar situation for when snippets are inserted as part of autocompletions is solved by the client announcing the An alternative would be to declare in the specs that SnippetTextEdits are only allowed to contain a single tab stop. Then clients could do a raw insert of the text and after that manually modify the cursor position in a second step. |
b8ba000 to
71ee753
Compare
|
@dbaeumer Should I make any changes to the metamodel, or is it done automatically? |
|
@dbaeumer with microsoft/vscode-languageserver-node#1414 fixed, I think this PR is ready :) |
|
I think we should add some additional clarification to the spec about some expectations. Things I have in mind:
Since snippets it workspace edits are most likely used with code actions there will be an open active editor to which snippets can be applied. @MariaSolOs can you add this to the PR? |
By "apply it to the file", do you mean the currently open editor, or the closed one specified by the snippet edit? If it's the currently opened editor, that sounds counterintuitive since the server (and user) expect the change to happen in the specified editor. If it's the non-active editor, how does that prevent the workspace from opening up random files? |
No to the file that is specific to the snippet edit without opening the file in the editor. This is what is done for normal text edits as well. |
5dc1c0d to
b4c489f
Compare
|
Just to confirm, because there wasn't any response to my question from #1892 (comment), and it's unclear from the text in the specs: Is it correct to assume that language servers have to figure out by themselves (for examply using the |
|
@jwortmann sorry for that. The |
The problem with view.run_command('insert_snippet', {'contents': edit['snippet']['value']})and without any means to change indentation behavior. I wonder how does VS Code solve this problem, because the comment I linked above (#724 (comment)) indicates that the same happens in VS Code. Also compare #83 (comment) explaining the "magic indentation" that happens in VS Code. As far as I understand, I described a possible workaround in my comment above, which should be sufficient if setting the final cursor position is the only goal of the SnippetTextEdit:
But in that case this should be explained in the specs. Because currently the snippet content only has a link to the StringValue, and its description explicitly mentions multiple tab stops. |
Follow-up of microsoft/vscode-languageserver-node#1343.
This time it actually closes #724.