#IEx.Autocomplete.expand slow when called manually

24 messages · Page 1 of 1 (latest)

rugged marsh
#

Tab completion in iex is instantaneous, but when I manually call 'someinput' |> Enum.reverse() |> IEx.Autocomplete.expand(), it takes several seconds to return completions. Any idea why, or how I can call this and get similarly instantaneous results? I do notice it takes an optional second argument that defaults to IEx.Broker.shell(); maybe that's something?

spare prairie
#

same thing happens for me. What are you trying to do?

rugged marsh
#

Write a small filter for rlwrap. My reasons are pretty specific, just need a way to get those autocompletes at a similar speed to hitting tab in iex

spare prairie
#

the iex autocompleter assumes you're in an IEX session, it's very use-specific

rugged marsh
#

Right. In this case though, I am in an IEx session, I'd just like to call the autocompleter directly

spare prairie
#

right, I'm saying that this won't work

rugged marsh
#

That's why I'm kind of wondering if the second argument would do something

spare prairie
#

all the broker does is find your iex session.

#

you're using a lot of internal modules

#

I don't think they're supposed to do what you're using them to do.

rugged marsh
#

I think expand is normally called from Erlang which passes in a pid. Maybe if I pass in the same pid Erlang does it'll be responsive. If that's the case, IEx.Broker.shell() isn't the right one

rugged marsh
spare prairie
#

i'm wondering if you'll get more mileage out of something like elixir_sense.

rugged marsh
#

If there's no way to call this function and get a quick return, maybe I can figure out how to use ElixirLS to give me what I need

#

Haven't heard of that one, I'll check it out

spare prairie
#

elixir_sense is used by elixir_ls

#

elixir_ls is also not very reusable.

#

trust me.

rugged marsh
#

Gotcha

spare prairie
#

i'm deep in its code now

#

i guess the question I have is where does your shell context come from without a shell?

rugged marsh
#

This pretty much does what I need. The first call is slow but subsequent calls are fast. I can live with that

spare prairie
#

nice.

#

nitpick...

str
|> ElixirSense.suggestions(0, len + 1)
|> Enum.map(& &1.name)