Skip to content

Commit dcefbca

Browse files
author
José Valim
committed
Remove empty starts_with usage in IEx.Autocomplete
1 parent 060df75 commit dcefbca

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/iex/lib/iex/autocomplete.ex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ defmodule IEx.Autocomplete do
179179
defp match_aliases(hint) do
180180
for {alias, _mod} <- env_aliases(),
181181
[name] = Module.split(alias),
182-
String.starts_with?(name, hint) do
182+
starts_with?(name, hint) do
183183
%{kind: :module, type: :alias, name: name}
184184
end
185185
end
@@ -201,8 +201,8 @@ defmodule IEx.Autocomplete do
201201
defp match_modules(hint, root) do
202202
get_modules(root)
203203
|> :lists.usort()
204-
|> Enum.drop_while(& not String.starts_with?(&1, hint))
205-
|> Enum.take_while(& String.starts_with?(&1, hint))
204+
|> Enum.drop_while(& not starts_with?(&1, hint))
205+
|> Enum.take_while(& starts_with?(&1, hint))
206206
end
207207

208208
defp get_modules(true) do
@@ -247,7 +247,7 @@ defmodule IEx.Autocomplete do
247247

248248
for {fun, arities} <- list,
249249
name = Atom.to_string(fun),
250-
String.starts_with?(name, hint) do
250+
starts_with?(name, hint) do
251251
%{kind: :function, name: name, arities: arities}
252252
end |> :lists.sort()
253253

@@ -271,6 +271,9 @@ defmodule IEx.Autocomplete do
271271
defp ensure_loaded(mod),
272272
do: Code.ensure_compiled(mod)
273273

274+
defp starts_with?(_string, ""), do: true
275+
defp starts_with?(string, hint), do: String.starts_with?(string, hint)
276+
274277
## Ad-hoc conversions
275278

276279
defp to_entries(%{kind: :module, name: name}) do

0 commit comments

Comments
 (0)