-
Notifications
You must be signed in to change notification settings - Fork 209
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: truncate multiline completions by the next new sibling #1709
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.
Let's gooo!
// Remove the characters that are being replaced by the completion to avoid having | ||
// them in the parse tree. It breaks the multiline truncation logic which looks for | ||
// the increased number of children in the tree. | ||
const textWithCompletion = prefix + insertText + suffix.slice(matchingSuffixLength) |
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.
Would this work in cases where the insertion contains multiple insert blocks and the matchingSuffixLength
is not following right after another or am I misunderstanding something? 🤔
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.
Could you elaborate a bit more or share an example?
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.
I was thinking of a document state like this:
function bubbleSort(█){
and a completion like this:
function bubbleSort(items: any[]): any[] {
But since suffix
will be the suffix inside the document, it doesn't matter actually and it should work as expected.
// function test(one, two) {...} | ||
// | ||
// In this case, the logic will find the parameter list as a node with the updated number | ||
// of siblings. We get the expected result if we start from the "{" node. |
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.
I think I understand the intend here but I don't think it's guaranteed that the start of the block will be in the first line?
function test(█)
function test (
one,
two,
) {
//...
}
Is the worst case here that the truncation will stop with the multiple argument lines?
function test (
one,
two,
)
or how can I imagine this?
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.
Is the worst case here that the truncation will stop with the multiple argument lines?
Yes, in the case of the multiline argument list, we will stop at it.
const parsedFirstLine = parseCompletionFirstLineMemoized(firstLine, { | ||
document, | ||
docContext, | ||
}) |
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.
I don't understand under which situations this is called multiple lines? Is this for when a multi-line completion has three examples but all of them start with the same first line?
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.
It will be called multiple times from canUsePartialCompletion
with the tree-sitter-powered truncation. So, you are correct that it's not called numerous times in the current implementation. Memozation will be used in the follow-up PR.
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.
Makes sense!
Context
Test plan