Skip to content

Conversation

@godnight10061
Copy link
Contributor

@godnight10061 godnight10061 commented Jan 20, 2026

Fixes #2513.

  • Dragging a hunk now uses the selected line range (when present) instead of always using the full hunk.

Testing:

  • Local (Windows):
    • pnpm prettier
    • pnpm lint
    • pnpm check
    • pnpm test
    • cargo fmt --check --all
    • cargo check --workspace --all-targets
    • cargo check --workspace --all-targets --features windows

Before/After:

after.mp4
before.mp4

@vercel
Copy link

vercel bot commented Jan 20, 2026

@godnight10061 is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/desktop @gitbutler/ui labels Jan 20, 2026
@Byron Byron marked this pull request as draft January 21, 2026 09:07
Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for tackling this, this seems like something we really want fixed as it's surprising if the selection isn't respected.

There I wonder if the visualisation should also be indicating that it's just the selected lines that are dragged, it still looks like it's the entire hunk.

Meanwhile, let's also put it back into draft while there are conflicts. Maybe @mtsgrd or @Caleb-T-Owens can chime in to see if this generally the way to go in the frontend.

In the backend, I don't think any of the changes should be needed.

@godnight10061 godnight10061 force-pushed the fix/line-based-hunk-drag branch from 3ac4864 to a2f24ec Compare January 21, 2026 16:57
@mtsgrd
Copy link
Contributor

mtsgrd commented Jan 21, 2026

Indeed, thanks for putting together a fix for this. It was never implemented, by reasonably should. I see you've just recently pushed some more commits, and there's a lint issue there.. but let me check this branch out in a couple of hours, and we'll get it merged as soon as possible. 🙏

@godnight10061
Copy link
Contributor Author

godnight10061 commented Jan 22, 2026

@Byron @mtsgrd Thanks! I simply added a "selected lines" section right after the dragging hunk header. Would appreciate any UI ideas to make it even clearer.
Video:

dummyRepo.GitButler.Dev.2026-01-22.09-30-04.mp4

@Byron
Copy link
Collaborator

Byron commented Jan 22, 2026

Wow, I am loving it! Now it's not surprising anymore and the info-box one is dragging around has just the right size and information.

Something that my eye found less pleasing was the line break for 'lines'. Maybe removing the selected would already do it?

Screenshot 2026-01-22 at 06 45 35

@PavelLaptev would probably have some notes as well now.

@PavelLaptev
Copy link
Contributor

@godnight10061 thank you for he PR!

I noticed that we can select lines to drag if the change is assigned or unassigned.
However, hunks in committed changes can also be draggable (see video).
To maintain consistency, we should provide the same functionality in all places where we can drag hunks.

Screen.Recording.2026-01-22.at.13.15.11.mov

@Byron
Copy link
Collaborator

Byron commented Jan 22, 2026

Thanks a lot @PavelLaptev! Is this something that can be generalised in code so it's applied generically?
If not, then it would probably still make sense to take these changes one 'location' at a time to keep this PR small.

@PavelLaptev
Copy link
Contributor

Thanks a lot @PavelLaptev! Is this something that can be generalised in code so it's applied generically? If not, then it would probably still make sense to take these changes one 'location' at a time to keep this PR small.

I’m not sure if this can be generalized, but I believe it should be, or the behavior will be inconsistent.

@Byron Byron requested a review from estib-vega January 22, 2026 13:20
@PavelLaptev
Copy link
Contributor

@Byron, as we discussed this offline, we can merge this. However, let’s not forget to implement the ability to drag hunk lines in other places where it’s possible to do so.

with:
shared-key: e2e-blackbox-rust-binaries
save-if: ${{ github.ref == 'refs/heads/master' }}
- uses: dtolnay/rust-toolchain@stable

Check failure

Code scanning / zizmor

unpinned action reference

unpinned action reference
with:
shared-key: e2e-playwright-rust-binaries
save-if: ${{ github.ref == 'refs/heads/master' }}
- uses: dtolnay/rust-toolchain@stable

Check failure

Code scanning / zizmor

unpinned action reference

unpinned action reference
@godnight10061 godnight10061 force-pushed the fix/line-based-hunk-drag branch from 546d7d1 to abd12e0 Compare January 24, 2026 05:46
@godnight10061 godnight10061 force-pushed the fix/line-based-hunk-drag branch from 1a907d6 to f2b2bdc Compare January 25, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@gitbutler/desktop @gitbutler/ui rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move line-based changes around (instead of hunk-based changes)

4 participants