gitui icon indicating copy to clipboard operation
gitui copied to clipboard

Allow to scroll diffs horizontally

Open cruessler opened this issue 3 years ago • 11 comments

This Pull Request fixes/closes #1017.

This is an attempt to finish the work started by @M1cha. It fixes a few minor issues, makes clippy pass and was rebased onto the latest master.

I followed the checklist:

  • [ ] I added unittests
  • [x] I ran make check without errors
  • [x] I tested the overall application
  • [x] I added an appropriate item to the changelog (an item was already added)

cruessler avatar Sep 13 '22 20:09 cruessler

that looks way better!

one thing is left that bothers: the hunk header also scrolls. can we keep that static?

extrawurst avatar Sep 14 '22 10:09 extrawurst

I kinda liked that it does so you can see the whole thing in case it doesn't fit the screen.

M1cha avatar Sep 14 '22 10:09 M1cha

I think I agree with @M1cha. I like that you can see each hunk’s header, and I imagine scrolling might feel broken if you weren’t able to do that.

cruessler avatar Sep 14 '22 14:09 cruessler

ok cool with me. I keep scrolling left and rush up the file tree in the end :( on the other hand I really do not want to introduce a special horizontal scrolling key binding... any ideas?

extrawurst avatar Sep 14 '22 14:09 extrawurst

can we see the difference between keyrepeat and keypress? if yes, disabling leaving the view through keyrepeat might at least allow to scroll to the very left by holding down the arrow-keys without the risk of accidentally leaving the view.

M1cha avatar Sep 14 '22 14:09 M1cha

unfortunately this is only supported in a very limited amount of terminals: https://github.com/crossterm-rs/crossterm/pull/688

extrawurst avatar Sep 14 '22 16:09 extrawurst

I lean towards making this more explicit and going into a fullscreen diff view (no file tree on the left anymore) when starting to scroll right and only allowing to leave that one via esc

extrawurst avatar Sep 14 '22 16:09 extrawurst

sounds good to me

M1cha avatar Sep 14 '22 17:09 M1cha

Sounds good to me, too! I’ll try to update this PR next week, probably Tuesday or Wednesday. Would we still have the diff view to the right as long as it doesn’t have focus?

cruessler avatar Sep 16 '22 17:09 cruessler

Yeah exactly! Thanks ❤️

extrawurst avatar Sep 17 '22 09:09 extrawurst

DiffComponent is used in 3 places, InspectCommitComponent, CompareCommitsComponent, and FileRevlogComponent. I changed all 3 parent components to have the diff full screen as soon as it gets focus. Is this the right direction? Then we could maybe start fine-tuning and polishing. What do you think?

cruessler avatar Sep 22 '22 17:09 cruessler

yeah all places behaving the same sounds reasonable. after all we won't change the current behaviour we just add the "press right to open in fullscreen" option from each

extrawurst avatar Oct 19 '22 14:10 extrawurst

@cruessler any blockers on this?

extrawurst avatar Oct 26 '22 12:10 extrawurst

@cruessler 🥺

extrawurst avatar Nov 14 '22 12:11 extrawurst

@extrawurst I believe I was waiting for feedback after my last comment. I will check (and rebase in the process)! Sorry for not responding!

cruessler avatar Nov 21 '22 08:11 cruessler

@extrawurst I’ve rebased the PR! I briefly checked that horizontal scrolling works by making my terminal smaller. The diff view is now full-screen, so that scrolling is required in fewer cases. It closes when you’re at scroll position 0 and press left arrow. Let me know what’s missing!

cruessler avatar Nov 27 '22 12:11 cruessler

this looks good already just a few small improvements:

  • lets have the same behaviour in the status tab when moving right on a (horizontally-)scrollable diff
  • lets not use the left key to leave the fullscreen, this happens weirdly when holding down the left-arrow
  • use esc like in other places to leave the fullscreen again
  • lets show the scrollbar already once the scrollable diff is focused

extrawurst avatar Nov 27 '22 20:11 extrawurst

@extrawurst In the status tab, do we want to keep the current behaviour of having the diff not go fullscreen on focus? I think it makes sense to make it consistent with the other places DiffComponent is used and also go fullscreen.

cruessler avatar Dec 02 '22 14:12 cruessler

works better now IMO.

in the status tab I would say lets go to fullscreen once the right command is pressed to scroll and there is actually something to scroll.

extrawurst avatar Dec 06 '22 08:12 extrawurst

works better now IMO.

in the status tab I would say lets go to fullscreen once the right command is pressed to scroll and there is actually something to scroll.

@extrawurst If I understand the architecture correctly, this is not that easy to accomplish. The code that knows whether a scrollbar is necessary, lives in DiffComponent while the code that decides how much space to give to the DiffComponent lives in Status. The state “would a scrollbar be drawn” is currently not easily shareable it seems. Do you have a solution for that issue? Am I overlooking something?

cruessler avatar Dec 24 '22 15:12 cruessler

@cruessler yeah you are right. lets go to fullscreen on right either way

extrawurst avatar Jan 03 '23 19:01 extrawurst

@extrawurst I updated the Status tab, rebased and briefly checked that everything still works. As far as I can see, the Status tab was the last thing in your list of feedback.

cruessler avatar Jan 04 '23 12:01 cruessler

It works really well as far as I can see! Will review later and merge 🥳

extrawurst avatar Jan 04 '23 12:01 extrawurst

just a very small thing I would prefer to see cleaned up. @cruessler let me know if you got time for it shortly otherwise we can merge and clean them up later

Thanks for the suggestion! I can most likely address it over the weekend.

cruessler avatar Jan 04 '23 18:01 cruessler

Thank you so much

extrawurst avatar Jan 08 '23 11:01 extrawurst