-
Notifications
You must be signed in to change notification settings - Fork 240
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 not trigger a completion if a single-line completion was accepted #2446
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Some feedback inline about readable tests.
vscode/src/completions/get-inline-completions-tests/no-request-when-accepting.test.ts
Outdated
Show resolved
Hide resolved
} | ||
) | ||
) | ||
).not.toEqual<V>(null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
// Thus, this results in a request that almost always has zero results but still incurs network | ||
// and inference costs. | ||
it('should not make a request after accepting a completion', async () => { | ||
const initialRequestParams = params( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test and the next one would be more readable if they used a helper function that's parameterized on the trigger kind to show that, exact same situation with implicit trigger doesn't cause a follow on completion attempt, but manual trigger does.
The difference in trigger kind is only one line, it is hard to spot it in the midst of the rest of the test code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
muuuch better 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…-when-accepting.test.ts Co-authored-by: Dominic Cooney <dominic.cooney@sourcegraph.com>
This is a small optimization that should cut down a bit on unnecessary LLM request:
In VS Code, if you accept a completion, this changes the document and thus issue a new completion request. Makes sense! The thing is: we always complete full lines so the chance that you do want a follow-up completion is very slim. In some cases the ending
)
or;
helps to guard against this but not in all cases.This PR adds a special logic now to detect this case and not issue a completion (so accepting a completion via
tab
won't issue a new request but any further keystroke (likeenter
) will).Test plan
Screen.Recording.2023-12-20.at.15.33.07.mov