Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix completion-filtering by checking actual word boundaries & reduce Ruby word chars #9170

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

mrnugget
Copy link
Member

@mrnugget mrnugget commented Mar 11, 2024

This fixes #9069 by

  1. reverting Ruby: Code Completion not working  #7819
  2. fixing completion filtering with regards to word boudaries

For (2) see explanation in commit message:

Previously, this would only split words on upper-lower boundaries or
on _/-.

The result was that we would filter out completions too aggressively.
The filter works by taking a suggested completion, say foo_bar_lol, split
it up into words - foo, bar, lol- and check whether any of the words start with the same characters as what the user already typed:fo, or bar`,
...

In the case of Ruby, though, : wasn't considered a word boundary. If the
LSP would return :foobar when the user typed :foo, we'd check if there are
any completions that match foo (because that's the current word) but
we'd compare against foobar, not : or :foobar.

With this change, we get more match candidates and thus more completions in Ruby.

With that we can do (1) because we don't need these characters as word characters anymore to trigger completions.

Release Notes:

  • Fixed word boundaries in Ruby by restoring old behavior (@, :, ... are no longer considered word characters) (#9069)
  • Fixed completions being filtered out when they happened at word boundaries on special characters (e.g. :)

This does not work, because I can't define an override for
`simple_symbol` it seems.

In a Ruby program that looks like this:

```ruby
:foo
```
with cursor on last `o`, the `node` that's used for override query
lookup used is not `simple_symbol`, but `program`, the root node.

And for that no overrides are found.

Do overrides only work for nodes that can have children?
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 11, 2024
mrnugget and others added 2 commits March 11, 2024 20:20
Previously, this would only split words on upper-lower boundaries or
on `_`/`-`.

The result was that we would filter out completions too aggressively.
The filter works by taking a suggested completion, say `foo_bar_lol`, split
it up into words - `foo`, `bar, `lol` - and check whether any of the words
start with the same characters as what the user already typed: `fo`, or `bar`,
...

In the case of Ruby, though, `:` wasn't considered a word boundary. If the
LSP would return `:foobar` when the user typed `:foo`, we'd check if there are
any completions that match `foo` (because that's the current word) but
we'd compare against `foobar`, not `:` or `:foobar`.

With this change, we get more match candidates and thus more completions in Ruby.

Co-authored-by: Max <[email protected]>
This builds on top of 66a0e4d. Due to 66a0e4d we don't need these
anymore to trigger completions. So we can remove them and restore expected
navigational/selection behavior.

Co-authored-by: Max <[email protected]>
@mrnugget mrnugget changed the title NOT WORKING: Remove : from Ruby word chars, only use in symbols Fix completion-filtering by checking actual word boundaries & reduce Ruby word chars Mar 11, 2024
@mrnugget mrnugget marked this pull request as ready for review March 11, 2024 19:38
@mrnugget mrnugget merged commit b2981f4 into main Mar 11, 2024
11 checks passed
@mrnugget mrnugget deleted the ruby-colon-word branch March 11, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recent Ruby changes add more keystrokes for me: class names and symbols
1 participant