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

add SnippetTextEdit, allow drop-handler to return them #146312

Merged
merged 3 commits into from
Mar 31, 2022
Merged

Conversation

jrieken
Copy link
Member

@jrieken jrieken commented Mar 30, 2022

This helps with #142990. Adds SnippetTextEdit and wires this into the onWillDropOnTextEditor-proposal.

vscode.workspace.onWillDropOnTextEditor(e => {
  e.waitUntil(Promise.resolve(new vscode.SnippetTextEdit(
    new vscode.Range(e.position, e.position),
    new vscode.SnippetString('Hel$0lo ${1|World,Welt,Mondo|}. This is a ${2:snippet}-$2-$2')
  )))
})
Screen.Recording.2022-03-30.at.12.04.06.mov

Open questions

  1. How to prevent multiple snippets from being returned. Provider approach might help
  2. Be graceful when an editor isn't available and turn a snippet text edit into a normal edit (no really a problem with dnd into editors thi)

@jrieken jrieken requested a review from mjbvz March 30, 2022 10:08
@jrieken jrieken added this to the April 2022 milestone Mar 30, 2022
@jrieken jrieken self-assigned this Mar 30, 2022
Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!

The new api looks good to me. Once this is merged, I'll clean up the proposed on-drop api

@jrieken jrieken merged commit 6dde517 into main Mar 31, 2022
@jrieken jrieken deleted the joh/snippetTextEdit branch March 31, 2022 17:07
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants