File tree Expand file tree Collapse file tree
lib/elixir_console_web/live Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } } ->
You can’t perform that action at this time.
0 commit comments