Skip to content

Wrong syntax highlighting for triple-quoted F-strings #25798

Description

Type: Bug

Behaviour

It is confused by standalone triple quotes as beginning a docstring comment.

Steps to reproduce:

  1. Open a new tab with this snippet:
def foo():
    """
    Sample function that does nothing.
    """

    return f"""
        This is a {foo.__name__} multi-line string that is returned by 
        the function.
    """

def bar():
    """
    Wrong highlighting ends on the opening triple quotes of the docstring 
    of this function.
    """

    return ""
Image

Diagnostic data

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

2026-02-16 08:19:45.318 [info] Native locator: Refresh started
2026-02-16 08:19:45.318 [info] Skipping ActivatedEnv Detection:  process.env.VSCODE_CLI !== '1'
2026-02-16 08:19:45.318 [info] > conda info --json
2026-02-16 08:19:45.380 [info] > pyenv which python
2026-02-16 08:19:45.380 [info] cwd: .
2026-02-16 08:19:46.310 [info] Python interpreter path: ./.venv/bin/python
2026-02-16 08:19:46.396 [info] Native locator: Refresh finished in 1592 ms
2026-02-16 08:19:47.862 [info] Starting Pylance language server.

Extension version: 2026.0.0
VS Code version: Code 1.109.3 (b6a47e94e326b5c209d118cf0f994d6065585705, 2026-02-12T17:54:48.470Z)
OS version: Darwin arm64 25.2.0
Modes:

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


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
append-comma vco 0.0.1
azure-dev ms- 0.10.0
better-cpp-syntax jef 1.27.1
catppuccin-vsc Cat 3.18.1
catppuccin-vsc-icons Cat 1.26.0
catppuccin-vsc-pack cat 1.0.2
cmake twx 0.0.17
cmake-tools ms- 1.22.27
code-runner for 0.12.2
codesnap adp 1.3.4
copilot-chat Git 0.37.6
cpptools ms- 1.30.5
cpptools-extension-pack ms- 1.3.1
cpptools-themes ms- 2.0.0
csdevkit ms- 2.10.3
csharp ms- 2.120.3
cucumberautocomplete ale 3.1.0
custom-ui-style sub 0.6.7
dart-code Dar 3.128.0
debugpy ms- 2025.18.0
docker doc 0.18.0
docomment k-- 1.0.1
docs-view bie 0.1.0
doxdocgen csc 1.4.0
durablefunctionsmonitor Dur 6.7.3
EditorConfig Edi 0.18.1
editorconfiggenerator nep 0.2.1
elixir-ls Jak 0.30.0
elm-ls-vscode elm 2.8.0
emojisense bie 0.10.0
es6-string-html Tob 2.17.0
even-better-toml tam 0.21.2
flutter Dar 3.128.0
git-project-manager fel 1.8.2
githistory don 0.6.20
github-markdown-preview bie 0.3.0
gitignore cod 0.10.0
gitlens eam 17.10.0
go gol 0.52.2
isort ms- 2025.0.0
javascript-ejs-support Dig 1.3.3
jinjahtml sam 0.20.0
js-debug ms- 1.105.0
js-debug-companion ms- 1.1.3
jsdoc-markdown-highlighting bie 0.0.1
json-minifier Ren 0.0.2
jupyter ms- 2025.9.1
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.3.0
language-gettext mro 0.5.0
markdown-all-in-one yzh 3.6.3
markdown-checkbox bie 0.4.0
markdown-emoji bie 0.3.1
markdown-footnotes bie 0.1.1
markdown-image-size bie 0.0.4
markdown-mermaid bie 1.32.0
markdown-preview-enhanced shd 0.8.20
markdown-preview-github-styles bie 2.2.0
markdown-shiki bie 0.1.1
markdown-yaml-preamble bie 0.1.0
material-icon-theme PKi 5.31.0
mdc Nux 0.5.0
mermaid-markdown-syntax-highlighting bpr 1.7.6
metals sca 1.63.0
microsoft-testing ms- 0.2.0
migrate-java-to-azure vsc 1.12.1
ng-template Ang 21.1.1
noctis liv 10.43.3
pascalcase-camelcase-to-snakecase-converter mar 0.2.2
pgformatter bra 1.33.0
plantuml jeb 2.18.1
postcss css 1.0.9
prettier-vscode esb 12.3.0
protobuf-vsc DrB 1.6.0
pubspec-assist jer 2.3.2
pulumi-lsp-client pul 0.2.3
pulumi-vscode-copilot pul 0.3.4
pulumi-vscode-tools pul 0.4.0
python ms- 2026.0.0
rainbow-csv mec 3.24.1
remote-containers ms- 0.442.0
remote-explorer ms- 0.5.0
remote-ssh ms- 0.122.0
remote-ssh-edit ms- 0.87.0
rest-client hum 0.25.1
ruff cha 2026.36.0
scala sca 0.5.9
shader sle 1.1.5
significant-other jas 0.3.0
slidev ant 52.12.0
terraform has 2.37.7
test-adapter-converter ms- 0.2.1
todo-tree Gru 0.0.226
trailing-semicolon nau 1.0.2
vscode-as-git-mergetool zaw 0.14.0
vscode-azure-github-copilot ms- 1.0.153
vscode-azure-mcp-server ms- 1.0.1
vscode-azureappservice ms- 0.26.4
vscode-azurecontainerapps ms- 0.10.0
vscode-azurefunctions ms- 1.20.3
vscode-azureresourcegroups ms- 0.12.0
vscode-azurestaticwebapps ms- 0.13.2
vscode-azurestorage ms- 0.17.1
vscode-azurevirtualmachines ms- 0.6.10
vscode-bicep ms- 0.40.2
vscode-containers ms- 2.4.1
vscode-cosmosdb ms- 0.30.2
vscode-docker ms- 2.0.0
vscode-dotnet-runtime ms- 3.0.0
vscode-eslint dba 3.0.20
vscode-github-actions git 0.31.0
vscode-graphql Gra 0.13.2
vscode-graphql-execution Gra 0.3.2
vscode-graphql-syntax Gra 1.3.8
vscode-java-upgrade vsc 1.12.1
vscode-js-profile-table ms- 1.0.10
vscode-json5 mrm 1.0.0
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
vscode-markdown-everywhere zha 0.0.17
vscode-monorepo-workspace fol 1.3.1
vscode-node-azure-pack ms- 1.8.0
vscode-peacock joh 4.2.2
vscode-pgsql ms- 1.16.0
vscode-pylance ms- 2025.10.4
vscode-python-envs ms- 1.16.0
vscode-sort-json ric 1.20.0
vscode-sql-template-literal for 0.1.0
vscode-tailwindcss bra 0.14.29
vscode-test-explorer hbe 2.22.1
vsfire tob 1.4.1
vshaxe nad 2.34.2
System Info
Item Value
CPUs Apple M4 (10 x 2400)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x106b [Google Inc. (Apple)], DEVICE=0x0000 [ANGLE (Apple, ANGLE Metal Renderer: Apple M4, Version 26.2 (Build 25C56))], DRIVER_VENDOR=Apple, DRIVER_VERSION=26.2 ACTIVE
Machine model name: Mac
Machine model version: 16.13
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: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 24.00GB (0.07GB free)
Process Argv --crash-reporter-id 012f170b-434c-4e5e-95e0-9d04fe31a27c
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31436602
aj953862:31281341
6abeh943:31336334
cloudbuttont:31379625
3efgi100_wstrepl:31403338
839jf696:31457053
use-responses-api:31390855
je187915:31401257
ec5jj548:31422691
cmp-ext-treat:31426748
cp_cls_c_966_ss:31454199
ge8j1254_inline_auto_hint_haiku:31431912
nes-autoexp-10:31446583
a5gib710:31434435
38bie571_auto:31461585
rename_enabled:31436409
7a04d226_do_not_restore_last_panel_session:31438103
anthropic_thinking_c:31457102
722j7530_gpt_5_2_codex:31458091
h0hdh950:31428394
preserve_tokens:31444547
cp_cls_c_1081:31454833
copilot-nes-oct-trt:31432596
ia-use-proxy-models-svc:31452481
nes-slash-models-on:31441832
nes-set-to-on:31441941
a43f0574a:31442826
e9c30283:31461165
c0ci8992_validated:31449878
nes-fast-additive:31462666
control_6dc23131:31461115
9c05b404_max_request_50:31461828
edit_mode_hidden:31461530
864ei723_large_tool_results_to_disk:31460878
reg-2ge67640:31455970
nes-extended-on:31455476
chat:31457767
ah:31460422

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions