livebook-dev / livebook

Automate code & data workflows with interactive Elixir notebooks

Home Page:https://livebook.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Completion of struct fields doesn't work when code is split over multiple lines.

aymanosman opened this issue · comments

Completion of struct fields doesn't work when code is split over multiple lines.

Current behavior

Screenshot 2024-02-16 at 17 32 13

If it is not clear from the image, the code looks like this:

%Foo{
  # <= cursor here
}

Expected behavior

To act the same way as a single line expression.

Screenshot 2024-02-16 at 17 31 59

@jonatanklosko maybe if the current line is empty, we should send the previous line as well for completion purposes?

Previous line may not be enough:

%Foo{
  foo: 1,
  bar: 2,
  # <= cursor here
}

The same issue concerns multiline bitstrings.

For signature we get all text until cursor, but signature request happens relatively rarely. Since autocompletion is enabled on typing by default, we make much more such requests, so we want to minimise the amount of text we send.

We could use AST information on the client side to get the broader scope in the several cases where we know it's relevant.

Erm..., I didn't expect you to fix it in less than a day. Mind blown.