microsoft / microsoft/monaco-editor

[Bug] Highlight exception in multi line string text of python code

Open
#4,939 0 comments 0 reactions 0 assignees View on GitHub

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

https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.2#XQAAAAJVAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzUw3RgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKijyMr2IOMNNkzzV-JhLQq-CjCJo1w9v01kEsFxW5Q4BF-OnC3dvNOr1OcBrTpg4qPbSEmd_-n3aRiMeebBnKONBIOg9ynvJM1drZiAhzhtqYoIi8Dhshu1EJ0AvsGO5zpsOMVGs-2Gf5RYPxNt-omzhaSW6lKgWx8afEpJetSb3d5Tifc0Bo7d-AvjGPnHkiE_7rSG8aq0HqpA8ZRm4Y6qowjS-pPEVycYH-yyNm

Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `a = f'''
line1
line2
print('error')
'''`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: 'python',
	automaticLayout: true,
});
Reproduction Steps

If f'''xxxxxx''' is used to represent a multi line string, only the first line is recognized as a string

Actual (Problematic) Behavior

The second to fourth lines should be highlighted as strings, but in reality, only the second line is highlighted as a string

Expected Behavior

Highlight multiple lines of string normally

Additional Context

No response

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 and its TypeScript reproduction using the Python language mode. Confirm that the multiline f-string highlights only its first line, then trace the Python syntax-highlighting behavior involved. Done means all lines inside the multiline string, including the line containing print('error'), are highlighted as string text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
developer-experience, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.