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

Safer incremental sync #1222

Merged
merged 1 commit into from
Feb 24, 2022
Merged

Conversation

plux
Copy link
Contributor

@plux plux commented Feb 23, 2022

  • didOpen: Handle indexing through els_index_buffer to avoid race
  • didSave: Read and index file through els_index_buffer, this should introduce a
    synchronization point if the index data has become out of sync.

Fixes some of the issues raised in #1220.
We still need to implement support for didChangeWatchedFiles

* didOpen: Handle indexing through els_index_buffer to avoid race
* didSave: Read and index file through els_index_buffer, this should introduce a
synchronization point if the index data has become out of sync.
@@ -42,6 +43,15 @@ apply_edits_async(Uri, Edits) ->
?SERVER ! {apply_edits, Uri, Edits},
ok.

-spec load(uri(), binary()) -> ok.
Copy link
Member

Choose a reason for hiding this comment

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

As a follow up, we should probably convert this to a gen server.

TextDocument = maps:get(<<"textDocument">>, Params),
Uri = maps:get(<<"uri">> , TextDocument),
#{<<"textDocument">> := #{<<"uri">> := Uri}} = Params,
{ok, Text} = file:read_file(els_uri:path(Uri)),
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how this play with different editors. Both in Emacs and VS Code, if the current version of the "buffer" is different from disk, you get a warning. Maybe it doesn't matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this should be fine as if we get didSave my assumption is that it must mean that the file has been written to disk.

@robertoaloi robertoaloi merged commit e45d7ae into erlang-ls:main Feb 24, 2022
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