slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 602 forks source link

LSP: race condition with diagnostics from the preview #5798

Closed ogoffart closed 2 months ago

ogoffart commented 3 months ago

This is reproducable both in slintpad and vscode when the preview is visible

Imagine a component with something like

Text {
   font-size:24;
}

Of course this is an error. Add px, by quickly typing p then x and notice that you still get an error that p is not an unit.

image

What I think happens is that:

  1. User add a p, editor send that to the LSP
  2. Both the LSP language thread and preview thread parses that.
  3. Language thread comes with an error quickly, but preview thread is a bit slower
  4. User add x, editor sends that to LSP
  5. language thread clears error with the new version
  6. preview thread just get finished and report error from the old version and report that to the editor
  7. preview thread finally finishes the new version, but don't report the absence of error to the editor. So the editor still see the error from old version.

We do report the error from the preview and the language thread separately, because the preview do more passes and therefore can catch errors that the language thread doesn't. But it seems we don't clear error from the preview thread when there are no more errors

hunger commented 3 months ago

5805 should make this one much more bearable.

ogoffart commented 3 months ago

https://github.com/slint-ui/slint/pull/5805 should make this one much more bearable.

I didn't notice any change. Still really easy to reproduce on slintpad, and vscode when the preview is visible.

hunger commented 3 months ago

Yes, I did not claim it was fixed, the text is just updated now so you have a chance for the issue to fix itself again.

ogoffart commented 2 months ago

Fixed by https://github.com/slint-ui/slint/pull/5875