Skip to content

Commit

Permalink
correctly encode output messages as binary
Browse files Browse the repository at this point in the history
Fixes elixir-lsp/vscode-elixir-ls#322
Bug introduced in #457
  • Loading branch information
lukaszsamson committed Apr 20, 2023
1 parent bf9db5a commit 18aedca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions apps/elixir_ls_utils/lib/output_device.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ defmodule ElixirLS.Utils.OutputDevice do
@moduledoc """
Intercepts IO request messages and forwards them to the Output server to be sent as events to
the IDE. Implements [Erlang I/O Protocol](https://erlang.org/doc/apps/stdlib/io_protocol.html)
In order to send console output to Visual Studio Code, the debug adapter needs to send events
using the usual wire protocol. In order to intercept the debugged code's output, we replace the
registered processes `:user` and `:standard_error` and the process's group leader with instances
of this server. When it receives a message containing output, it sends an event via the `Output`
server with the correct category ("stdout" or "stderr").
"""

@opts binary: true, encoding: :unicode
@opts binary: true, encoding: :latin1

## Client API

Expand Down
2 changes: 1 addition & 1 deletion apps/elixir_ls_utils/test/output_device_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ defmodule ElixirLS.Utils.OutputDeviceTest do
output_device: output_device
} do
send(output_device, {:io_request, self(), 123, :getopts})
assert_receive({:io_reply, 123, [binary: true, encoding: :unicode]})
assert_receive({:io_reply, 123, [binary: true, encoding: :latin1]})
end

test "valid can be set", %{
Expand Down

0 comments on commit 18aedca

Please sign in to comment.