Skip to content

Commit a916cf4

Browse files
committed
Fix a bug in option keys validation
1 parent 3e9b618 commit a916cf4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/iex/lib/iex/options.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ defmodule IEx.Options do
124124

125125
def set(:colors, colors) when is_list(colors) do
126126
old_colors = get(:colors)
127-
# Validate keys before setting
128-
filtered_colors = Enum.filter colors, fn {name, _} ->
129-
name in old_colors
130-
end
127+
filtered_colors = filtered_kw(old_colors, colors)
131128
:application.set_env(:iex, :colors, Keyword.merge(old_colors, filtered_colors))
132129
old_colors
133130
end
@@ -138,10 +135,7 @@ defmodule IEx.Options do
138135

139136
def set(:inspect, opts) when is_list(opts) do
140137
old_opts = get(:inspect)
141-
# Validate keys before setting
142-
filtered_opts = Enum.filter opts, fn {name, _} ->
143-
name in old_opts
144-
end
138+
filtered_opts = filtered_kw(old_opts, opts)
145139
:application.set_env(:iex, :inspect_opts, Keyword.merge(old_opts, filtered_opts))
146140
old_opts
147141
end
@@ -186,4 +180,10 @@ defmodule IEx.Options do
186180
defp raise_value do
187181
raise ArgumentError, message: "Expected the value to be a keyword list"
188182
end
183+
184+
defp filtered_kw(reference_kw, user_kw) do
185+
Enum.filter user_kw, fn {name, _} ->
186+
Keyword.has_key? reference_kw, name
187+
end
188+
end
189189
end

0 commit comments

Comments
 (0)