luau icon indicating copy to clipboard operation
luau copied to clipboard

Fragment autocomplete does not suggest keywords correctly

Open JohnnyMorganz opened this issue 9 months ago • 1 comments

Reported from https://github.com/JohnnyMorganz/luau-lsp/issues/948

luau-lsp relies on Luau's AutocompleteContext to determine whether it is valid to suggest auto-requires at the current location. i.e., we should only suggest them if the context accepts an expression.

However, when enabling fragment autocomplete, it does not suggest keywords correctly when expected. The context remains an expression, leading to auto-require suggestions showing up.

Can be seen in the following example:

if true th|

With Fragment Autocomplete (luau-lsp.completion.enableFragmentAutocomplete):

Image

Without Fragment Autocomplete:

Image

This becomes problematic because VSCode will accept an autocompletion suggestion when a newline is entered, causing a bad autocomplete:

https://github.com/user-attachments/assets/5c9e5e1d-4a40-483f-abb1-224c96f9e0f6

JohnnyMorganz avatar Mar 16 '25 11:03 JohnnyMorganz

Thanks for reporting this! I'm going to file a ticket and we'll solve this after some of the major polish fixes go out for fragment autocomplete.

Vighnesh-V avatar Mar 17 '25 18:03 Vighnesh-V