Skip to content

Cursor jumps to end of file when formatting files with large tuples #17572

@rintrint

Description

@rintrint

Summary

When formatting Python files with large tuples (>20K chars), the cursor jumps to the end of file. This only happens when:

  1. The tuple is very large (>20K characters)
  2. The formatter makes significant changes, causing a delay
  3. The cursor is positioned INSIDE the large tuple when formatting is triggered

I've tested that:

  • Reducing tuple size to <20K chars fixes the issue
  • Files with 30K+ char tuples but minimal formatting changes don't have this issue

The problem seems related to both tuple size AND amount of reformatting needed.

Reproducible with this file:
https://github.com/MMD-Blender/blender_mmd_tools/blob/6ae13d6039763b6813832622c13da464983e93b3/mmd_tools/m17n.py

Version

VS Code: 1.99.3
Ruff extension: 2025.22.0
OS: Windows_NT x64 10.0.19045

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions