Skip to content

Autocomplete for string literal values fails when typing "/" #31304

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

Closed
gr2m opened this issue May 8, 2019 · 5 comments · Fixed by #31362
Closed

Autocomplete for string literal values fails when typing "/" #31304

gr2m opened this issue May 8, 2019 · 5 comments · Fixed by #31362
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Fixed A PR has been merged for this issue

Comments

@gr2m
Copy link

gr2m commented May 8, 2019

TypeScript Version: [email protected]

Search Terms: is:issue is:open slash in:title , autocomplete in:title , is:open label:"Domain: Completion Lists"

Code

type Options = "one/two/three" | "two/three/one" | "three/one/two" 

function test(option: Options) {}

test("")

Expected behavior:

The suggested options for test() should update as I type the string. It should not be interrupted when I type "/" and it should not match all options when I type "one/" and press control space to trigger the auto complete

Actual behavior:

When I start typing "one" it will correctly list the three possible options

image

As soon as I type "one/" the autocomplete disappears

image

When I continue typing "one/two" all the options appear again, although only one of them should match

image

When I then select the "one/two/three" option, it adds the whole string

image

Playground Link: playground

Related Issues: follow up to octokit/endpoint.js#23 (comment)

@weswigham weswigham added Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor labels May 8, 2019
@a-tarasyuk
Copy link
Contributor

@weswigham I think it happens because the following condition is equal tofalse for the string enum values which include /

case "/":
return !!contextToken && (isStringLiteralLike(contextToken)
? !!tryGetImportFromModuleSpecifier(contextToken)
: contextToken.kind === SyntaxKind.SlashToken && isJsxClosingElement(contextToken.parent));

What do you think about ignoring / char for this case? Maybe there is helper which can be used to determine that it is string enum value.

@weswigham
Copy link
Member

isValidTrigger should probably ignore unmatching quotes and all other triggers when within a string literal. Probably. I at least can't imagine why you'd want @ to trigger while you're in a string literal already.

@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.6.0 milestone May 24, 2019
@DanielRosenwasser DanielRosenwasser changed the title Autocomplete for enum values fails when typing "/" Autocomplete for string literal values fails when typing "/" May 24, 2019
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label May 24, 2019
@DanielRosenwasser
Copy link
Member

Thanks @a-tarasyuk!

@gr2m
Copy link
Author

gr2m commented May 24, 2019

😍 Thank you so much!

Will you add a comment when the fix was released? Or is it automatically published to the @next dist-tag? I couldn’t find any documentation on your process here, apologies if I missed it

@DanielRosenwasser
Copy link
Member

It'll be in the next nightly, but 3.5 should be out next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Completion Lists The issue relates to showing completion lists in an editor Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants