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

lsp: Offer to populate empty documents #4767

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hunger
Copy link
Member

@hunger hunger commented Mar 6, 2024

So when snippets do not work: Let's try something else to get started from scratch:-)

image

@hunger
Copy link
Member Author

hunger commented Mar 6, 2024

Of course this only shows while the file does not contain anything but whitespace:-)

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. I like it.

I think only one option is enough though.
Probably the Hello World like so:

import { AboutSlint, VerticalBox } from "std-widgets.slint";

export component MainWindow inherits Window {
    VerticalBox {
        alignment: start;
        Text { text: "Hello World!"; }
        AboutSlint { preferred-height: 150px; }
    }
}

Make it a window by default. But keep it as short as possible while still have something somehow visual.

Did you try if it worked in a slint!{} macro?

if let Some(current_version) = version {
if current_version != source_version {
return Err(
"Document version mismatch. Please refresh your command data".into()
Copy link
Member

Choose a reason for hiding this comment

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

This is the kind of error that is seen by the user when something goes wrong in synchronization. But users will have no idea how to "refresh their command data".

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, when that happens the LSP stops anyway :-)

I'll just return "OK" and be done with that...

if let Some(range) = util::map_node(node) {
let has_non_ws_token = node
.children_with_tokens()
.any(|nt| nt.kind() != SyntaxKind::Whitespace && nt.kind() != SyntaxKind::Eof);
Copy link
Member

Choose a reason for hiding this comment

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

Should we also accept a comment? (eg license header comments)

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you try if it worked in a slint!{} macro?

Yes and that fails hard:-/

It replaces the entire rust code.

@hunger
Copy link
Member Author

hunger commented Mar 6, 2024

We need to remember which area of the document we are actually touching... otherwise this just can not work.

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.

None yet

2 participants