-
Notifications
You must be signed in to change notification settings - Fork 203
Labels
Description
Describe the Bug
from typing import Literal
def foo(fruit: Literal["apple", "pear"]):
...
foo(''Python: 3.12
When the cursor is in between the quotes, the auto-complete populates the literals correctly. Then if I select one of the options, the post-completion state becomes
foo(''apple''
which didn't take into account the existing quote marks and is incorrect.
On a side note, the current auto-complete doesn't handle strings with quotes correctly --- which is an orthogonal issue with lower priority.
Relevant code pointer:
pyrefly/pyrefly/lib/state/lsp.rs
Line 1934 in 4ffa2e0
| fn add_literal_completions_from_type(param_type: &Type, completions: &mut Vec<CompletionItem>) { |
Presumably this call wraps the string into another layer of single quotes
pyrefly/pyrefly/lib/state/lsp.rs
Line 1938 in 4ffa2e0
| label: lit.to_string(), |
| Lit::Str(x) => write!(f, "'{x}'"), |
Sandbox Link
(Only applicable for extension issues) IDE Information
No response