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: trigger multiline completions on empty block only #1052

Merged
merged 3 commits into from
Sep 15, 2023

Conversation

valerybugakov
Copy link
Member

@valerybugakov valerybugakov commented Sep 14, 2023

Context

// Previously generated multi-line completions.
function bubbleSort() {
   const a = []
}
// We request multi-line completions only for empty blocks now.
function bubbleSort() {
   
}

Test plan

Added unit-tests.

@valerybugakov valerybugakov requested a review from a team September 14, 2023 02:47
@valerybugakov valerybugakov self-assigned this Sep 14, 2023
@valerybugakov valerybugakov marked this pull request as ready for review September 14, 2023 02:48
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.

Hmmm interesting... I can still reproduce the issue but only on line n -> n+1 , it doesn't seem to be an issue for the lines after that (see loom for details) ...?🤔
(It's kinda late here so i haven't really paid attention to the change, will look at it more closel.y tmr and let you know if i find anything!)

Loom: https://www.loom.com/share/9790bc66ac9847af920d92a1720e62a9?sid=a14685fa-79c3-4ba1-a48f-21b11cc9a309

Current:
image

Infill prompt
image

@valerybugakov valerybugakov requested a review from a team September 14, 2023 06:15
@valerybugakov
Copy link
Member Author

Hey @abeatrix, thanks for sharing the Loom video!

I'm confused because you demonstrate single-line completions inside a non-empty block unrelated to changes in this PR. However, I see the issue with duplicated suffixes in your video. Could you elaborate on what problem you refer to above?

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.

Awesomesauce

Comment on lines +38 to +40
// Only trigger multiline suggestions when the next non-empty line is indented less
// than the block start line (the newly created block is empty).
indentation(currentLinePrefix) >= indentation(nextNonEmptyLine)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we extract this into a variable and use the same var in the check below to avoid duplication?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to do that, but we rely on the currentLinePrefix indentation for the openingBracketMatch and prevNonEmptyLine indentation for the empty line case.

@@ -82,33 +79,55 @@ describe('[getInlineCompletions] triggers', () => {
},
})
)
expect(requests).toHaveLength(1)
expect(requests[0].stopSequences).toContain(MULTILINE_STOP_SEQUENCE)
expect(requests).toBeSingleLine()
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

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.

Hey @abeatrix, thanks for sharing the Loom video!

I'm confused because you demonstrate single-line completions inside a non-empty block unrelated to changes in this PR. However, I see the issue with duplicated suffixes in your video. Could you elaborate on what problem you refer to above?

Sorry I just rebuilt and tried again this morning, and I can't reproduce the issue I posted to you anymore so maybe it was a caching issue? I can open a new issue if it comes back to me but like you mentioned, it's not what your PR is trying to cover so LGTM! Thanks for clarifying!

@valerybugakov valerybugakov merged commit 8efaaff into main Sep 15, 2023
13 checks passed
@valerybugakov valerybugakov deleted the vb/multiline-trigger-empty-block branch September 15, 2023 01:31
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.

None yet

3 participants