Skip to content

Formatting replaces the entire file #383

@WhyNotHugo

Description

@WhyNotHugo

When formatting a file, ruff will replace the entire file with a formatted copy. It should only replace lines that have changed (as far as I can tell, this is what most LSPs do).

The issue with replacing the whole file, is that (at least on neovim) the cursor position is reset to the beginning of the file on background windows/splits, because the entire file was deleted/replaced.

Reproduction steps

  • Open a well formatted file in neovim
  • Open a split window (:vsp)
  • Scroll on window to the middle of the file
  • Switch to the unscrolled window
  • Add an empty line at the beginning of the file
  • Format the file using ruff-lsp

The cursor for the second split will now jump to the top of the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestvimRelated to the Neo(Vim) editor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions