Skip to content

Accepting completions from LSP in some cases leads to invalid syntax #209

@winwinashwin

Description

@winwinashwin

I came across a peculiar scenario at https://shinylive.io where the code edits made after accepting a LSP completion item is incorrect.

import random
import typing as t

myfunc: t.Callable[[], t.Literal['yes', 'no']] = lambda: random.choice(['yes', 'no'])

if myfunc() == '  # autocomplete is triggered here

Suggestions from LSP (as expected) -

Image

Code after accepting the suggestion

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions