Fragment autocomplete does not suggest keywords correctly
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):
Without Fragment Autocomplete:
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
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.