Skip to content

fix(expert): use document from request as fallback when document is not in the store#695

Merged
katafrakt merged 2 commits into
v0.1from
backport-693-to-v0.1
May 27, 2026
Merged

fix(expert): use document from request as fallback when document is not in the store#695
katafrakt merged 2 commits into
v0.1from
backport-693-to-v0.1

Conversation

@katafrakt
Copy link
Copy Markdown
Member

Manual backport of #693

…ot in the store (#693)

Looking at #535 the reason is that a file on which a codeAction request
is performed is not (yet?) in the `Document.Store` (or maybe was there,
but is gone because of `didClose`). This smells like a misbehaving
client, but I cannot rule out some kind of race condition too.

Anyway, even if we cannot fetch from `Document.Store` for some reason,
we should already have a document resolved from the request (by
temporary reading from disk). We can use this document as a fallback in
such case. Not sure if it fixes #535, because I don't have a repro case,
but it's the best shot I have.

(cherry picked from commit 5daee68)
Comment thread apps/expert/lib/expert.ex

def handle_request(request, lsp) do
with {:ok, handler} <- fetch_handler(request),
{:ok, request} <- Convert.to_native(request),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It seems in v1 we had first Convert.to_native, then check_engine_initialized, but in main the other way around. Not sure when/why this happened.

@katafrakt katafrakt marked this pull request as draft May 25, 2026 09:30
@katafrakt katafrakt marked this pull request as ready for review May 26, 2026 07:40
@katafrakt
Copy link
Copy Markdown
Member Author

This is a bit non-trivial backport because of differences between v0.1 and main, so if you could have a look when you have time @doorgan I'd be grateful for a second pair of eyes.

Copy link
Copy Markdown
Contributor

@doorgan doorgan 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 and worked in my tests!

@katafrakt katafrakt merged commit 2c66a26 into v0.1 May 27, 2026
38 checks passed
@katafrakt katafrakt deleted the backport-693-to-v0.1 branch May 27, 2026 07:21
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.

2 participants