Skip to content

Commit 4552443

Browse files
committed
improve message formatting in debugger
1 parent a7ae832 commit 4552443

File tree

1 file changed

+12
-4
lines changed
  • apps/elixir_ls_debugger/lib/debugger

1 file changed

+12
-4
lines changed

apps/elixir_ls_debugger/lib/debugger/output.ex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,27 @@ defmodule ElixirLS.Debugger.Output do
3030
end
3131

3232
def debugger_console(server \\ __MODULE__, str) when is_binary(str) do
33-
send_event(server, "output", %{"category" => "console", "output" => str})
33+
send_event(server, "output", %{"category" => "console", "output" => maybe_append_newline(str)})
3434
end
3535

3636
def debugger_important(server \\ __MODULE__, str) when is_binary(str) do
37-
send_event(server, "output", %{"category" => "important", "output" => str})
37+
send_event(server, "output", %{"category" => "important", "output" => maybe_append_newline(str)})
3838
end
3939

4040
def debuggee_out(server \\ __MODULE__, str) when is_binary(str) do
41-
send_event(server, "output", %{"category" => "stdout", "output" => str})
41+
send_event(server, "output", %{"category" => "stdout", "output" => maybe_append_newline(str)})
4242
end
4343

4444
def debuggee_err(server \\ __MODULE__, str) when is_binary(str) do
45-
send_event(server, "output", %{"category" => "stderr", "output" => str})
45+
send_event(server, "output", %{"category" => "stderr", "output" => maybe_append_newline(str)})
46+
end
47+
48+
defp maybe_append_newline(message) do
49+
unless String.ends_with?(message, "\n") do
50+
message <> "\n"
51+
else
52+
message
53+
end
4654
end
4755

4856
## Server callbacks

0 commit comments

Comments
 (0)