Skip to content

Hash symbol highlighted as comment in triple-quoted raw strings #7813

@regob

Description

@regob

Type: Bug

Behaviour

Hash symbol (#) is syntax highlighted as comment in multiline raw strings, while in such cases it does not start a comment as per the language grammar.

Steps to reproduce:

Create a python file and insert the following code:

s = r"""
this should not be presented as comment: # comment here
"""
s = r'''
this should not be presented as comment: # comment here
'''
s_nonraw = """
this should not be presented as comment: # comment here
"""
ss_raw = r"this should not be presented as comment: # comment here"
Image

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2025-12-29 21:17:04.170 [info] Experiment 'pythonRecommendTensorboardExt' is active
2025-12-29 21:17:04.170 [info] Experiment 'pythonREPLSmartSend' is active
2025-12-29 21:17:04.170 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2025-12-29 21:17:04.170 [info] Experiment 'pythonTestAdapter' is active
2025-12-29 21:17:04.170 [info] Skipping ActivatedEnv Detection:  process.env.VSCODE_CLI !== '1'
2025-12-29 21:17:04.170 [info] > conda info --json
2025-12-29 21:17:04.173 [info] Python interpreter path: /bin/python
2025-12-29 21:17:04.280 [info] > /usr/share/anaconda/bin/conda info --json
2025-12-29 21:17:04.884 [info] > ~/.conda/bin/conda info --json
2025-12-29 21:17:04.889 [info] > ~/.condarc/bin/conda info --json
2025-12-29 21:17:05.875 [info] > ~/.conda/envs/vehicle_mtmc/bin/conda info --json
2025-12-29 21:17:06.908 [info] Starting Pylance language server.

Extension version: 2025.20.1
VS Code version: Code 1.107.1 (994fd12f8d3a5aa16f17d42c041e5809167e845a, 2025-12-17T14:15:14.850Z)
OS version: Linux x64 6.17.8-200.fc42.x86_64
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.13.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
User Settings


venvFolders: "<placeholder>"

languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
autodocstring njp 0.6.1
autopep8 ms- 2025.2.0
Bookmarks ale 13.5.0
cmake-tools ms- 1.21.36
copilot-chat Git 0.33.5
cpptools ms- 1.29.3
debugpy ms- 2025.19.2025121701
emacs-mcx tut 0.65.1
gruvbox-themes tom 1.0.0
js-debug ms- 1.105.0
js-debug-companion ms- 1.1.3
jupyter ms- 2025.9.1
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.3.0
markdown-all-in-one yzh 3.6.3
MetaJump met 1.4.4
powershell ms- 2025.4.0
prettier-vscode esb 11.0.2
python ms- 2025.20.1
quarto qua 1.127.0
r REd 2.8.6
r-syntax REd 0.1.3
rainbow-csv mec 3.23.0
remote-explorer ms- 0.5.0
remote-server ms- 1.5.3
remote-ssh ms- 0.120.0
remote-ssh-edit ms- 0.87.0
ruff cha 2025.32.0
shell-format fox 7.2.8
vscode-dotnet-runtime ms- 3.0.0
vscode-js-profile-table ms- 1.0.10
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-language-babel mgm 0.0.40
vscode-pylance ms- 2025.10.4
vscode-python-envs ms- 1.15.13521014
System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i5-13400 (16 x 2835)
GPU Status 2d_canvas: enabled
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off
Load (avg) 1, 1, 1
Memory (System) 31.08GB (23.98GB free)
Process Argv --crash-reporter-id f17ad074-a1de-4627-8608-c69721ec0c08
Screen Reader no
VM 0%
DESKTOP_SESSION plasmax11
XDG_CURRENT_DESKTOP KDE
XDG_SESSION_DESKTOP KDE
XDG_SESSION_TYPE x11

Metadata

Metadata

Assignees

Labels

ai-triage-respondedIndicate whether the AI triage agent has responded to this issue.bugSomething isn't workingtextmate bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions