diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2019-01-30 22:39:54 +0100 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2019-01-30 22:40:13 +0100 |
commit | 322ce6d8c2afd75ae79ecff1bf6005be317a09c1 (patch) | |
tree | c2b668f0a22cc54f3ef6d73b90e832788cf08291 | |
parent | a87d39ed050bb381caf6c7b6532c4bb338e7c513 (diff) | |
download | elixir-322ce6d8c2afd75ae79ecff1bf6005be317a09c1.tar.gz |
Bring back autocomplete for remote nodes, closes #8743
-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 |