Skip to content

diff: preserve shared suffixes for prefixed lines - #9916

Closed
subotac wants to merge 1 commit into
jj-vcs:mainfrom
subotac:fix/conflict-color-words-prefix
Closed

diff: preserve shared suffixes for prefixed lines#9916
subotac wants to merge 1 commit into
jj-vcs:mainfrom
subotac:fix/conflict-color-words-prefix

Conversation

@subotac

@subotac subotac commented Aug 4, 2026

Copy link
Copy Markdown

Alternative to #9915. This takes a narrower approach by keeping the correction in the color-words renderer instead of changing the general diff matching algorithm.

When an inline diff line consists of one removed and one added hunk, and one side differs only by a prefix, only that prefix is styled as changed. The shared suffix remains unstyled.

Fixes #9914.

Checklist

  • I have updated CHANGELOG.md
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited it.

A multi-line word diff can fail to find an anchor for a repeated line in a
materialized conflict. The inline renderer then receives the full left and
right lines as changed even when one differs only by a marker prefix.

Recognize that two-hunk prefix-only case while rendering color-words output.
Compare line contents without their endings, style only the inserted or
removed prefix, and leave the shared suffix unstyled. This keeps the
correction local to presentation without changing the general diff matching
heuristics.

Add a CLI regression for the repeated conflict lines and document the fix.

Fixes jj-vcs#9914
@subotac
subotac requested a review from a team as a code owner August 4, 2026 21:52
@google-cla

google-cla Bot commented Aug 4, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@yuja

yuja commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This should probably be handled within the diff logic. The --git diff share the same issue, though its output is less obvious.

@subotac

subotac commented Aug 5, 2026

Copy link
Copy Markdown
Author

Agreed. This belongs in the shared diff logic so --git and color-words stay consistent. #9915 implements that at the algorithm layer with regression coverage, so this renderer-only alternative is redundant. I will close this in favor of #9915.

@subotac subotac closed this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

color-words diff of a conflict: + prefix misrendered on last line of section

2 participants