Skip to content

Allow to scroll diffs horizontally #1327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jan 8, 2023

Conversation

cruessler
Copy link
Collaborator

@cruessler cruessler commented Sep 13, 2022

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
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog (an item was already added)

Feedback 2022-11-27

#1327 (comment)

  • 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
Copy link
Collaborator

that looks way better!

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

@M1cha
Copy link

M1cha commented Sep 14, 2022

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

@cruessler
Copy link
Collaborator Author

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.

@extrawurst
Copy link
Collaborator

extrawurst commented Sep 14, 2022

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?

@M1cha
Copy link

M1cha commented Sep 14, 2022

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.

@extrawurst
Copy link
Collaborator

unfortunately this is only supported in a very limited amount of terminals: crossterm-rs/crossterm#688

@extrawurst
Copy link
Collaborator

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

@M1cha
Copy link

M1cha commented Sep 14, 2022

sounds good to me

@cruessler
Copy link
Collaborator Author

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?

@extrawurst
Copy link
Collaborator

Yeah exactly! Thanks ❤️

@cruessler
Copy link
Collaborator Author

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?

@extrawurst
Copy link
Collaborator

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
Copy link
Collaborator

@cruessler any blockers on this?

@extrawurst
Copy link
Collaborator

@cruessler 🥺

@cruessler
Copy link
Collaborator Author

@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 cruessler force-pushed the diff-horizontal-scroll branch from 7e92601 to 0d20806 Compare November 27, 2022 10:52
@cruessler
Copy link
Collaborator Author

@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!

@extrawurst
Copy link
Collaborator

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

@cruessler
Copy link
Collaborator Author

@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.

@extrawurst
Copy link
Collaborator

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.

@cruessler cruessler force-pushed the diff-horizontal-scroll branch from 45100a0 to d3dd3a7 Compare December 24, 2022 15:00
@cruessler
Copy link
Collaborator Author

cruessler commented Dec 24, 2022

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?

@extrawurst
Copy link
Collaborator

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

M1cha and others added 7 commits January 4, 2023 10:50
the diff viewer will need it in a future commit
converting tabs to spaces had to be moved from after the formatting to
before it because `trim_offset` seems to remove leading tabs from the output
string (not the input string) for some reason.

calculating the longtest line is cached to prevent a theoretical
decrease in performance.
@cruessler cruessler force-pushed the diff-horizontal-scroll branch from d3dd3a7 to 51d7eb9 Compare January 4, 2023 10:10
@cruessler
Copy link
Collaborator Author

@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.

@extrawurst
Copy link
Collaborator

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

Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

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

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

@cruessler
Copy link
Collaborator Author

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.

@extrawurst
Copy link
Collaborator

Thank you so much

@extrawurst extrawurst merged commit 9fa5fdd into gitui-org:master Jan 8, 2023
extrawurst pushed a commit that referenced this pull request Jan 13, 2023
IndianBoy42 pushed a commit to IndianBoy42/gitui that referenced this pull request Jun 4, 2024
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.

Allow to scroll diffs horizontally
3 participants