Skip to content

Commit 829cf38

Browse files
committed
Merge branch 'master' into heex
2 parents cebc868 + 455207a commit 829cf38

6 files changed

Lines changed: 16 additions & 172 deletions

File tree

.credo.exs

Lines changed: 0 additions & 154 deletions
This file was deleted.

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}} ->

lib/elixir_console_web/live/console_live/command_input_component.html.heex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
autocomplete="off"
99
autofocus
1010
name="command"
11-
phx-target="#command_input"
1211
phx-hook="CommandInput"
1312
data-input_value={@input_value}
1413
data-caret_position={@caret_position}

mix.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ defmodule ElixirConsole.MixProject do
4040
{:jason, "~> 1.0"},
4141
{:plug_cowboy, "~> 2.1"},
4242
{:earmark, "~> 1.4.0"},
43-
{:dialyxir, "~> 0.5.1", only: :dev},
4443
{:floki, "~> 0.31.0", only: :test},
4544
{:sentry, "~> 7.0"},
4645
{:wallaby, "~> 0.28", only: :test, runtime: false}

mix.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
44
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.1", "ebd1a1d7aff97f27c66654e78ece187abdc646992714164380d8a041eda16754", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a6efd3366130eab84ca372cbd4a7d3c3a97bdfcfb4911233b035d117063f0af"},
55
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
6-
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm", "6c32a70ed5d452c6650916555b1f96c79af5fc4bf286997f8b15f213de786f73"},
76
"earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"},
87
"earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"},
98
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},

test/elixir_console_web/live/console_live_test.exs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ defmodule ElixirConsoleWeb.ConsoleLiveTest do
102102
test "show suggestions if more than one", %{conn: conn} do
103103
{:ok, view, _html} = live(conn, "/")
104104

105-
input = element(view, "#command_input input")
106-
render_hook(input, :suggest, %{"value" => "Enum.co", "caret_position" => 7})
105+
view
106+
|> with_target("#command_input")
107+
|> render_hook(:suggest, %{"value" => "Enum.co", "caret_position" => 7})
107108

108109
html = render(view)
109110

@@ -113,8 +114,9 @@ defmodule ElixirConsoleWeb.ConsoleLiveTest do
113114
test "autocomplete and do not show suggestions if only one", %{conn: conn} do
114115
{:ok, view, _html} = live(conn, "/")
115116

116-
input = element(view, "#command_input input")
117-
render_hook(input, :suggest, %{"value" => "Enum.conc", "caret_position" => 9})
117+
view
118+
|> with_target("#command_input")
119+
|> render_hook(:suggest, %{"value" => "Enum.conc", "caret_position" => 9})
118120

119121
html = render(view)
120122

@@ -127,8 +129,9 @@ defmodule ElixirConsoleWeb.ConsoleLiveTest do
127129
test "show suggestions considering caret position in the command input", %{conn: conn} do
128130
{:ok, view, _html} = live(conn, "/")
129131

130-
input = element(view, "#command_input input")
131-
render_hook(input, :suggest, %{"value" => "Enum.co([1,2]) - 2", "caret_position" => 7})
132+
view
133+
|> with_target("#command_input")
134+
|> render_hook(:suggest, %{"value" => "Enum.co([1,2]) - 2", "caret_position" => 7})
132135

133136
html = render(view)
134137

@@ -138,10 +141,10 @@ defmodule ElixirConsoleWeb.ConsoleLiveTest do
138141
test "autocomplete considering caret position in the command input", %{conn: conn} do
139142
{:ok, view, _html} = live(conn, "/")
140143

141-
input = element(view, "#command_input input")
142-
143144
html =
144-
render_hook(input, :suggest, %{"value" => "Enum.conc([1,2], [3])", "caret_position" => 9})
145+
view
146+
|> with_target("#command_input")
147+
|> render_hook(:suggest, %{"value" => "Enum.conc([1,2], [3])", "caret_position" => 9})
145148

146149
assert html =~ ~r/\<input .* data-input_value\="Enum.concat\(\[1,2\], \[3\]\)"/
147150
assert html =~ ~r/\<input .* data-caret_position\="11"/

0 commit comments

Comments
 (0)