From eb066cf76050c321a294fcc8591529c8976d729e Mon Sep 17 00:00:00 2001 From: Vlad Dumitrescu Date: Wed, 21 Jun 2017 20:08:41 +0200 Subject: [PATCH] fix text conversions: expect unicode --- common/apps/erlide_builder/src/erlide_builder.erl | 2 +- ide/apps/erlide_ide_core/src/erlide_scanner.erl | 2 +- server/apps/erlide_server/src/erlide_lsp_server.erl | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/apps/erlide_builder/src/erlide_builder.erl b/common/apps/erlide_builder/src/erlide_builder.erl index 235de6c..f801193 100644 --- a/common/apps/erlide_builder/src/erlide_builder.erl +++ b/common/apps/erlide_builder/src/erlide_builder.erl @@ -71,7 +71,7 @@ compile_options(F, Options, OutputDir) -> format_compile_msg(L, Marker) when is_list(L) -> lists:flatten([format_compile_msg(X, Marker) || X <- L]); format_compile_msg({File, L}, Marker) -> - [{Ln, File, iolist_to_binary(M:format_error(D)), Marker} || {Ln, M, D} <- L]. + [{Ln, File, unicode:characters_to_binary(lists:flatten(M:format_error(D))), Marker} || {Ln, M, D} <- L]. mk_includes(L) -> [{i, X} || X <- L]. diff --git a/ide/apps/erlide_ide_core/src/erlide_scanner.erl b/ide/apps/erlide_ide_core/src/erlide_scanner.erl index adf6d05..1f7ca53 100644 --- a/ide/apps/erlide_ide_core/src/erlide_scanner.erl +++ b/ide/apps/erlide_ide_core/src/erlide_scanner.erl @@ -135,5 +135,5 @@ convert_tokens(Tokens) -> G = case is_list(Txt) of true -> length(Txt); _ -> byte_size(Txt) end, <<(kind_small(Kind)), L:24, O:24, G:24>> end, - erlang:iolist_to_binary([Fun(X) || X <- Tokens]). + unicode:characters_to_binary(lists:flatten([Fun(X) || X <- Tokens])). diff --git a/server/apps/erlide_server/src/erlide_lsp_server.erl b/server/apps/erlide_server/src/erlide_lsp_server.erl index b828cf7..5c360da 100644 --- a/server/apps/erlide_server/src/erlide_lsp_server.erl +++ b/server/apps/erlide_server/src/erlide_lsp_server.erl @@ -168,7 +168,7 @@ handle_cast({'textDocument/rename', Id, #{textDocument:=#{uri:=URI}, position:=P handle_cast({show_message, Type, Msg}, State = #state{proxy = Proxy}) -> Proxy ! {notify, 'window/showMessage', #{type => Type, - message => iolist_to_binary(Msg)}}, + message => unicode:characters_to_binary(Msg)}}, {noreply, State}; handle_cast({show_message_request, Type, Msg, Actions, Pid}, State = #state{proxy = Proxy}) -> Id = State#state.crt_id, @@ -178,14 +178,14 @@ handle_cast({show_message_request, Type, Msg, Actions, Pid}, State = #state{prox }, Proxy ! {request, Id, 'window/showMessageRequest', #{type => Type, - message => iolist_to_binary(Msg), + message => unicode:characters_to_binary(Msg), actions => Actions} }, {noreply, NewState}; handle_cast({log_message, Type, Msg}, State = #state{proxy = Proxy}) -> Proxy ! {notify, 'window/logMessage', #{type => Type, - message => iolist_to_binary(Msg)}}, + message => unicode:characters_to_binary(Msg)}}, {noreply, State}; handle_cast({telemetry_event, Msg}, State = #state{proxy = Proxy}) -> Proxy ! {notify, 'telemetry/event', Msg}, @@ -209,7 +209,7 @@ handle_cast({_F, _A}=Other, State) -> {noreply, State}; handle_cast({F, Id, A}, State) -> FN = atom_to_binary(F, latin1), - AN = iolist_to_binary(io_lib:format("~p~n", [A])), + AN = unicode:characters_to_binary(lists:flatten(io_lib:format("~p~n", [A]))), io:format("Unrecognized operation ~p~n", [{FN, AN}]), reply(State, Id, #{error => #{code => method_not_found, message => <<"Unrecognized method ", FN/binary,