jj icon indicating copy to clipboard operation
jj copied to clipboard

`ui.merge-editor = "vscode"` auto-formats incorrectly.

Open andriyDev opened this issue 4 months ago • 2 comments

Description

I'm not sure whether this is a vscode bug or a jj bug. When using vscode as a merge editor, once I save the merge, it autoformats my code. This is desirable, except that the auto format settings are not correct! My code is in Rust, and my rustfmt.toml sets tab_spaces = 2. This means after a merge, all my indentations expand to 4 wide (the default for Rust)!

Steps to Reproduce the Problem

  1. Set ui.merge-editor = "vscode" in jj config.
  2. Ensure vscode has "Format On Save" enabled.
  3. Create a Rust project (e.g., cargo new --lib test-proj) with a jj repo.
  4. Create rustfmt.toml in the project root with the contents tab_spaces = 2
  5. Modify the Rust code and save it in VSCode to autoformat the code.
  6. Create a merge conflict (e.g., change the same line in two separate commits, then rebase one on top of the other).
  7. Run jj resolve.
  8. Fix the conflict and save and quit.

Expected Behavior

The code doesn't change it's formatting - it should still have two-spaces per indent, since that is what my rustfmt says. The parts that were merged are formatted to the project's settings.

Actual Behavior

The entire file gets completely reformatted to the default formatting - 4 spaces per indent.

Specifications

  • Platform: Windows
  • Version: jj 0.32.0-44de571887f261a94f543d977a7ab3a9df918aba

andriyDev avatar Sep 06 '25 18:09 andriyDev

Might be related to the "path" of the merge editor?

Typical oversight when generating temporary (code) files - if it is inside eg. /tmp, then project-level formatting settings would not get applied (at least when using formatters that read their own configs).

jaens avatar Oct 18 '25 13:10 jaens

Typical oversight when generating temporary (code) files - if it is inside eg. /tmp, then project-level formatting settings would not get applied (at least when using formatters that read their own configs).

yes, this is an accurate description. Related https://github.com/jj-vcs/jj/issues/6540

PhilipMetzger avatar Oct 19 '25 15:10 PhilipMetzger