Skip to content

Commit b2d90c2

Browse files
authored
Only add non empty commands to history (#147)
1 parent faedd31 commit b2d90c2

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

lib/elixir_console_web/live/console_live.ex

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ defmodule ElixirConsoleWeb.ConsoleLive do
5050

5151
# This event comes from CommandInputComponent
5252
def handle_info({:execute_command, command}, socket) do
53-
history =
54-
if socket.assigns.history == [] do
55-
[command]
56-
else
57-
[command | socket.assigns.history]
58-
end
53+
history = add_command_to_history(command, socket.assigns.history)
5954

6055
case execute_command(command, socket.assigns.sandbox) do
6156
{:ok, result, sandbox} ->
@@ -82,6 +77,9 @@ defmodule ElixirConsoleWeb.ConsoleLive do
8277
end
8378
end
8479

80+
defp add_command_to_history("", history), do: history
81+
defp add_command_to_history(command, history), do: [command | history]
82+
8583
defp execute_command(command, sandbox) do
8684
case Sandbox.execute(command, sandbox) do
8785
{:success, {result, sandbox}} ->

0 commit comments

Comments
 (0)