Skip to content

Commit

Permalink
Do not read file from disk on didOpen (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed May 13, 2022
1 parent c19fb72 commit 2dfb48a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion apps/els_lsp/src/els_dt_document.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

-export([
new/3,
new/4,
pois/1,
pois/2,
get_element_at_pos/3,
Expand Down Expand Up @@ -168,9 +169,12 @@ delete(Uri) ->

-spec new(uri(), binary(), source()) -> item().
new(Uri, Text, Source) ->
new(Uri, Text, Source, _Version = null).

-spec new(uri(), binary(), source(), version()) -> item().
new(Uri, Text, Source, Version) ->
Extension = filename:extension(Uri),
Id = binary_to_atom(filename:basename(Uri, Extension), utf8),
Version = null,
case Extension of
<<".erl">> ->
new(Uri, Text, Id, module, Source, Version);
Expand Down
7 changes: 3 additions & 4 deletions apps/els_lsp/src/els_text_synchronization.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ did_open(Params) ->
<<"version">> := Version
}
} = Params,
{ok, Document} = els_utils:lookup_document(Uri),
NewDocument = Document#{text => Text, version => Version},
els_dt_document:insert(NewDocument),
els_indexing:deep_index(NewDocument),
Document = els_dt_document:new(Uri, Text, _Source = app, Version),
els_dt_document:insert(Document),
els_indexing:deep_index(Document),
ok.

-spec did_save(map()) -> ok.
Expand Down

0 comments on commit 2dfb48a

Please sign in to comment.