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

Autocomplete: do adjust a completion range if it does not match the current line suffix #1507

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

valerybugakov
Copy link
Member

Context

  • Fixes the issue where completions were needlessly hidden: myFunction(█) with the insert text being "one", false because the current line suffix ) was not present in the generated completion. However, we still adjusted the completion insertion range to include it.
  • Fixes the issue where all the generated completions were hidden, even if only one needed to be ignored. Now, we filter out invisible completions individually and keep visible completions if we have any.

Test plan

Added unit tests.

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the issue where completions were needlessly hidden: myFunction(█) with the insert text being "one", false because the current line suffix ) was not present in the generated completion. However, we still adjusted the completion insertion range to include it.

I found cases where completion is still not showing up because of current line suffix 🤔

image

image

Is this something else that's unrelated to the current issue?

@valerybugakov
Copy link
Member Author

valerybugakov commented Oct 27, 2023

@abeatrix, great catch! I debugged your examples locally and found out that we change completion insert ranges in two places:

  1. completion.range = getRangeAdjustedForOverlappingCharacters(completion, { position, currentLineSuffix })
  2. const vscodeInsertRange = new vscode.Range(start, end)

The second part doesn't care if the completion range already exists, so the logic in the post-processing call (1) does not affect the result.

I feel that this is one of these cases we bumped into frequently in the last month: we have multiple places implementing parts of the same logic, and they are not explicitly connected, which causes customer-facing bugs because it's impossible to keep all these pieces in our heads. The codebase snowballs. We should spend time streamlining the completion processing logic to clarify where specific changes are expected on the codebase architecture level (e.g., having one place where we operate on completion insert ranges or having one place for multiline truncation). Setting clear boundaries based on the current implementation would help us move faster with less time spent debugging such cases. WDYT?

cc @philipp-spiess @beyang

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you said makes a lot of sense to me but I'll defer to you and Philipp since you both know the code better than I do 😃 it sounds like my examples require additional follow-up work but shouldn't block what you fixed here?

@valerybugakov
Copy link
Member Author

it sounds like my examples require additional follow-up work but shouldn't block what you fixed here?

Yeah, I'm working on it now and will add them to the diff in this PR.

@valerybugakov
Copy link
Member Author

@abeatrix, I pushed the update: 3f64635 to account for cases you shared above. Could you take another look, please?

@valerybugakov valerybugakov requested review from abeatrix and a team October 27, 2023 07:03
@abeatrix
Copy link
Contributor

@valerybugakov sorry I spent too much time on the chat redesign pr and forgot to review this. Will do it first thing on Monday 🙇🏻‍♀️

Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks reasonable! TY! It's indeed concerning that we have two places where we expand the range, we should make the range required with the completion item, that should help!

@valerybugakov valerybugakov merged commit edc37a5 into main Oct 30, 2023
14 checks passed
@valerybugakov valerybugakov deleted the vb/completions-with-no-matching-suffix branch October 30, 2023 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants