-
Notifications
You must be signed in to change notification settings - Fork 754
Fix completions crash and enable contextual type completions in array literals #2258
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
|
This might be alright, but I don't know if this is the right layer to do this in. Maybe this is more of a language service thing to work off of? Is there some sort of missing element we can use instead of the Also, it does reveal an undesirable behavior in both the new and old codebases. // @filename: a.ts
let x: "foo" | "bar" = /*a*/;
// @filename: b.ts
let y: ["foo" | "bar", string] = [/*b*/];If you request completions at In the old codebase (and I assume with this fix?), you will not get these suggested at |
|
@copilot try to address. |
I'll address this by adding special handling for Working on this now.
Fixed in 90ca278 by handling
Both issues you mentioned are now resolved. |
… handling Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Completions panic with "index out of range [-1]" when requested inside
new Map([...])constructor at certain positions:Additionally, string literal completions were not being suggested in tuple contexts without typing a quote character first.
Changes
completions.go: Add special handling for
OpenBracketTokenandCommaTokenin array literalspreviousTokenis[, get contextual type for element at index 0previousTokenis,, count elements before cursor and get contextual type for next elementservices.go: Add
GetContextualTypeForArrayElementfunctiongetContextualTypeForElementExpressionfor language service useTests: Added
TestCompletionsInMapConstructorNoCrashandTestCompletionsInArrayLiteralWithContextualTypeBenefits
let y: ["foo" | "bar"] = [/*here*/]now suggests"foo"and"bar")Original prompt
new Map(...). #2254✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.