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 support for SnippetTextEdit vscode API #12047

Merged

Conversation

jonah-iden
Copy link
Contributor

@jonah-iden jonah-iden commented Jan 6, 2023

What it does

Closes: #12022

as described here this PR implements SnippetTextEdits the same way they are implemented in vscode. This adds the api to set them on Workspaceedits and sends them as TextEdits with the insertAsSnippet flag to the monaco editor.
Through the snippetController2 class those Edits can be applied to the current editor.
Should SnippetTextEdits be done on a file which editor is not currently active, they are transformed to just the text and applied as normal TextEdits.

It sadly seems both in vscode and theia this snippetTextEdit/SnippetController2 only supports snippets with a single tabstop. So tabbing through seems to not work yet in both IDEs.

How to test

I built a tiny vscode extension which is downloadable from here
snippet-text-edit-test-0.0.1.zip
or buildable from here https://github.com/jonah-iden/snippet-text-edit-test.

This just inserts a test snippetTextEdit at the start of the currently open file and a file called file2.json in the workspace root (this file needs to be created manually first).

you should see the snippet is inserted correctly at the start of the file and the cursor is moved to the tabstop and in file2.json its also inserted at the start of the file without moving the cursor.

Review checklist

Reminder for reviewers

@msujew msujew changed the title Jiden/snippet text edit vscode api 12022 Add support for SnippetTextEdit vscode API Jan 6, 2023
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

The CI fails with the current changes.

includiing support in WorkspaceEdit

Signed-off-by: Jonah Iden <[email protected]>
when not inserting as SnippetTextEdit

Signed-off-by: Jonah Iden <[email protected]>
@jonah-iden jonah-iden force-pushed the jiden/SnippetTextEdit-vscode-api-12022 branch from d897fea to 85c4cc3 Compare January 10, 2023 14:01
Signed-off-by: Jonah Iden <[email protected]>
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

The test extension seems to work well 👍 Just a few comments, see below.

packages/plugin-ext/src/plugin/types-impl.ts Outdated Show resolved Hide resolved
packages/monaco/src/browser/monaco-workspace.ts Outdated Show resolved Hide resolved
packages/monaco/src/browser/monaco-workspace.ts Outdated Show resolved Hide resolved
Signed-off-by: Jonah Iden <[email protected]>
jonah-iden and others added 2 commits January 11, 2023 15:12
Co-authored-by: Mark Sujew <[email protected]>
@vince-fugnitto vince-fugnitto added the vscode issues related to VSCode compatibility label Jan 11, 2023
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@JonasHelming
Copy link
Contributor

@msujew Do you want to merge this?

@msujew msujew merged commit 7c90401 into eclipse-theia:master Jan 16, 2023
@paul-marechal paul-marechal added this to the 1.34.0 milestone Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vscode] Support SnippetTextEdit
5 participants