microsoft / microsoft/monaco-editor

[Bug] new support for Python f-strings breaks with multi-line f-strings

Open
#4,601 10 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug editor-highlight
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?
Monaco Editor Playground Link

Link

CleanShot 2024-07-12 at 11 08 38@2x

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
  1. Configure an editor using the built-in python language
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.