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

vscode: add "wrap in element" code action #3420

Merged
merged 5 commits into from
Sep 7, 2023

Conversation

jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Sep 6, 2023

A little productivity booster for editing .slint files in VS Code:

vscode-wrap-in-element.mov

Notice that LSP code actions and workspace edits do not yet natively support snippets or allow specifying the cursor position (microsoft/language-server-protocol#724), which is necessary for pre-selecting "element" for conveniently typing in the desired type name. This limitation is worked around by registering an experimental "snippet text edit" capability for the client, guarding the snippet code action with a capability check on the server side, and finally, detecting and inserting the snippet on the client side (inspired by rust-analyzer and Dart-Code).

@ogoffart ogoffart requested a review from hunger September 6, 2023 20:55
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

tools/lsp/language.rs Outdated Show resolved Hide resolved
editors/vscode/src/extension.ts Show resolved Hide resolved
@hunger
Copy link
Member

hunger commented Sep 7, 2023

A cool feature, indeed. Thanks for implementing it.

Copy link
Member

@hunger hunger left a comment

Choose a reason for hiding this comment

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

Still some CI failures that seem to be related to the change.

@@ -621,7 +621,7 @@ fn set_binding_on_known_property(

// Find the indentation of the element itself as well as the indentation of properties inside the
// element. Returns the element indent followed by the block indent
fn find_element_indent(element: &ElementRc) -> Option<String> {
pub fn find_element_indent(element: &ElementRc) -> Option<String> {
Copy link
Member

Choose a reason for hiding this comment

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

This should probably get moved to a more discoverable place, now that it got promoted to a generic utility function.

That can be a separate patch and does not need to be done in here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. The comment looks outdated too. I can follow up with a separate PR.

@ogoffart ogoffart merged commit 5ce11e3 into slint-ui:master Sep 7, 2023
29 checks passed
@ogoffart
Copy link
Member

ogoffart commented Sep 7, 2023

thanks!

@jpnurmi jpnurmi deleted the vscode-wrap-in-element branch September 7, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants