Skip to content

Commit

Permalink
Bug fixes (#227)
Browse files Browse the repository at this point in the history
* Fix for #225

* Fix for #226

* Fixes #223

Co-authored-by: Wojtek Surowka <wojtek.surowka@thectgrid.com>
  • Loading branch information
wojteksurowka and Wojtek Surowka authored Feb 3, 2022
1 parent 7d8816e commit e6786db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions apps/erlangbridge/src/lsp_handlers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ textDocument_didChange(Socket, Params) ->
case filename:extension(File) of
".erl" ->
[ContentChange] = maps:get(contentChanges, Params),

gen_lsp_doc_server:set_document_attribute(File, contents, maps:get(text, ContentChange));
".hrl" ->
[ContentChange] = maps:get(contentChanges, Params),
gen_lsp_doc_server:set_document_attribute(File, contents, maps:get(text, ContentChange));
_ ->
ok
Expand Down Expand Up @@ -270,8 +272,8 @@ formatting(Contents) ->
file:delete(TempFile),
UpdatedContents.

-endif
-else
-endif.
-else.

formatting(Contents) ->
TempFile = mktemp(Contents),
Expand Down
8 changes: 4 additions & 4 deletions apps/erlangbridge/src/vscode_erlfmt_parse.yrl
Original file line number Diff line number Diff line change
Expand Up @@ -1005,13 +1005,13 @@ Erlang code.
-define(val(Tok), element(1, Tok)).

-define(range_anno(Tok1, Tok2), #{
location => map_get(location, ?anno(Tok1)),
end_location => map_get(end_location, ?anno(Tok2))
location => maps:get(location, ?anno(Tok1)),
end_location => maps:get(end_location, ?anno(Tok2))
}).

-define(range_upto_anno(Tok1, Tok2), #{
location => map_get(location, ?anno(Tok1)),
end_location => decrement_location(map_get(location, ?anno(Tok2)))
location => maps:get(location, ?anno(Tok1)),
end_location => decrement_location(maps:get(location, ?anno(Tok2)))
}).

%% Entry points compatible to old erl_parse.
Expand Down
6 changes: 3 additions & 3 deletions apps/erlangbridge/src/vscode_erlfmt_scan.erl
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,17 @@ get_inner_end_line(Anno) ->
element(1, get_anno(inner_end_location, Anno, get_anno(end_location, Anno))).

get_anno(Key, Anno) when is_map(Anno) ->
map_get(Key, Anno);
maps:get(Key, Anno);
get_anno(Key, Node) when is_tuple(Node) ->
map_get(Key, element(2, Node)).
maps:get(Key, element(2, Node)).

get_anno(Key, Anno, Default) when is_map(Anno) ->
maps:get(Key, Anno, Default);
get_anno(Key, Node, Default) when is_tuple(Node) ->
maps:get(Key, element(2, Node), Default).

update_anno(Key, Fun, Anno) when is_map(Anno) ->
Anno#{Key => Fun(map_get(Key, Anno))};
Anno#{Key => Fun(maps:get(Key, Anno))};
update_anno(Key, Fun, Node) when is_tuple(Node) ->
setelement(2, Node, update_anno(Key, Fun, element(2, Node))).

Expand Down

0 comments on commit e6786db

Please sign in to comment.