-
Notifications
You must be signed in to change notification settings - Fork 136
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
Safer incremental sync #1222
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,18 +46,19 @@ did_change(Params) -> | |
|
||
-spec did_open(map()) -> ok. | ||
did_open(Params) -> | ||
TextDocument = maps:get(<<"textDocument">>, Params), | ||
Uri = maps:get(<<"uri">> , TextDocument), | ||
Text = maps:get(<<"text">> , TextDocument), | ||
ok = els_indexing:index(Uri, Text, 'deep'), | ||
#{<<"textDocument">> := #{ <<"uri">> := Uri | ||
, <<"text">> := Text}} = Params, | ||
ok = els_index_buffer:load(Uri, Text), | ||
ok = els_index_buffer:flush(Uri), | ||
Provider = els_diagnostics_provider, | ||
els_provider:handle_request(Provider, {run_diagnostics, Params}), | ||
ok. | ||
|
||
-spec did_save(map()) -> ok. | ||
did_save(Params) -> | ||
TextDocument = maps:get(<<"textDocument">>, Params), | ||
Uri = maps:get(<<"uri">> , TextDocument), | ||
#{<<"textDocument">> := #{<<"uri">> := Uri}} = Params, | ||
{ok, Text} = file:read_file(els_uri:path(Uri)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
ok = els_index_buffer:load(Uri, Text), | ||
ok = els_index_buffer:flush(Uri), | ||
Provider = els_diagnostics_provider, | ||
els_provider:handle_request(Provider, {run_diagnostics, Params}), | ||
|
There was a problem hiding this comment.
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.