Python: Folding works only in `identation` mode

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The cursor IDE is not performing the expected behavior when editor.foldingStrategy is set to auto. Folding is only performed based on indentation. This means it is not possible to fold elements such as variables, f-strings, unless they are indented.

The bug has been described with screenshots here Can't fold docstrings n python and here Folding strategy is not working

It seems to be associated to the anysphere release and/or problems with pylance integration.

Is there any solution to this issue?

Steps to Reproduce

Please see the two posts referenced.

Expected Behavior

Please see the two posts referenced.

Operating System

Windows 10/11
Linux

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.7.46 (user setup)

VSCode Version: 1.99.3
Commit: b9e5948c1ad20443a5cecba6b84a3c9b99d62580
Date: 2025-10-14T01:21:46.830Z
Electron: 34.5.8
Chromium: 132.0.6834.210
Node.js: 20.19.1
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.22631

Does this stop you from using Cursor

No - Cursor works, but with this issue

Could you upvote / comment on this issue? support textDocument/foldingRange · Issue #308 · DetachHead/basedpyright

Our extension is based on basedpyright, and we’ll incorporate improvements that they make to their extension.

1 Like

Thank you!

Just upvoted it.

In case it helps, below are some additional examples of folding disparities between VSCode and Cursor.

In the examples below, I am explicitly setting "editor.defaultFoldingRangeProvider": "ms-python.vscode-pylance" in VSCode.

Notes:

  • The folding is correctly applied in VSCode despite indentation for the string and docstring variables, dictionary, and the multiline function. Cursor does not provide folding for the first three, and provides duplicate folding for the function.
  • This behavior in Cursor occurs despite setting editor.foldingStrategy: "auto" , which should automatically select the default language server to provide the folding strategy.

VSCode:

Cursor IDE:

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.