microsoft / microsoft/monaco-editor
[Bug] new support for Python f-strings breaks with multi-line f-strings
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
single_line_f_string f'''nothing {'to see'} here'''
multi_line_f_string = f"""first line looks fine
{'uh oh'}
now the highlighting is broken down here :(
"""
also = "it's broken highlighting for everything after"
four = 2 + 2
Reproduction Steps
- Configure an editor using the built-in python language
- Enter a multi-line f-string which has an expression after the 1st line
Actual (Problematic) Behavior
The portion of the f-string after the expression is highlighted as python code instead of a string, and then the closing f-string delimiter causes code after that to be highlighted as if it were a string
Expected Behavior
Self evident
Additional Context
I believe this was added with #4401, which notably does not have multi-line f-strings in its test coverage.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Monaco Editor playground reproduction and inspect the f-string support and test coverage introduced by #4401, which does not cover multiline f-strings. Reproduce an expression after the first line of a multiline f-string; done when the remaining string stays highlighted as a string and code after the closing delimiter returns to normal Python highlighting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100