diff options
-rw-r--r-- | lib/iex/lib/iex.ex | 9 | ||||
-rw-r--r-- | lib/iex/lib/iex/autocomplete.ex | 13 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/iex/lib/iex.ex b/lib/iex/lib/iex.ex index 33e77811a..0bf033fb5 100644 --- a/lib/iex/lib/iex.ex +++ b/lib/iex/lib/iex.ex @@ -794,10 +794,17 @@ defmodule IEx do defp set_expand_fun do gl = Process.group_leader() + expand_fun = + if node(gl) != node() do + IEx.Autocomplete.remsh(node()) + else + &IEx.Autocomplete.expand/1 + end + # expand_fun is not supported by a shell variant # on Windows, so we do two IO calls, not caring # about the result of the expand_fun one. - _ = :io.setopts(gl, expand_fun: &IEx.Autocomplete.expand/1) + _ = :io.setopts(gl, expand_fun: expand_fun) :io.setopts(gl, binary: true, encoding: :unicode) end diff --git a/lib/iex/lib/iex/autocomplete.ex b/lib/iex/lib/iex/autocomplete.ex index 9eeb83ff6..2731e1d09 100644 --- a/lib/iex/lib/iex/autocomplete.ex +++ b/lib/iex/lib/iex/autocomplete.ex @@ -2,6 +2,19 @@ defmodule IEx.Autocomplete do @moduledoc false @doc """ + Provides one helper function that is injected into connecting + remote nodes to properly handle autocompletion. + """ + def remsh(node) do + fn e -> + case :rpc.call(node, IEx.Autocomplete, :expand, [e]) do + {:badrpc, _} -> {:no, '', []} + r -> r + end + end + end + + @doc """ The expansion logic. Some of the expansion has to be use the current shell |