Closed musjj closed 2 months ago
I think there now is in the linked PR. :D
You're a machine 😆. Just tested it and it works well for me!
EDIT: Actually, it seems that when you're inside the section (e.g. a line in the recent commits) alt+{j,k}
doesn't directly move you between sections.
I see. Magit actually behaves like this, but I too think i'd prefer if it skipped above to the section hmm.
I haven't used magit in years, but there's this from the manual I linked above:
p (magit-section-backward)
When not at the beginning of a section, then move to the beginning of the current section. At the beginning of a section, instead move to the beginning of the previous visible section.
It looks like that it's supposed to move to the beginning of the section :thinking:
Got my magit here started on the side just to compare. I'm not exactly sure which things are considered sections in Magit. In Gitu they're the expandable/collapsible lines (log entries are not).
I updated the branch so that it (unlike Magit) skips these with alt-j/k now, it seems like a no-brainer.
Thanks, tested it again and it works better now! But it looks that it still doesn't work in the staged/unstaged changes, is it intentional?
No probs! I'm not sure I understand. could you describe more in details? I think maybe one thing that might seem confusing is that it is a tree of sections.
0 Staged Changes (section)
1 modified src/main.rs (section)
2 @@ ... @@ (section)
3 + test test
1 modified src/foobar.rs (section)
2 @@ ... @@... (section)
So moving up from "modified src/foobar.rs" takes me to the above sibling section "modified src/main.rs".
Ah, that makes sense. I guess this is where this keybind in magit would be useful:
^ (magit-section-up)
Move to the beginning of the parent of the current section.
Could this be implemented too?
It shouldn't be too hard.
From what I could tell from testing magit-section-up
in Magit, it would move like this:
0 Staged Changes <-+ ...to here
1 modified src/main.rs |
2 @@ ... @@ |
3 + test test |
1 modified src/foobar.rs <-+ from here
2 @@ ... @@...
I also noticed it would go to the top of the file if at level 0.
0 On branch ... <-+ ...to here
Your branch is ... |
|
0 Staged Changes <-+ From here
1 modified src/main.rs
2 @@ ... @@
3 + test test
1 modified src/foobar.rs
2 @@ ... @@...
I'm considering whether ^
should be the hotkey for this.
Could perhaps put it on alt+left / alt+h?
Or all of them, something else?
@musjj I renamed these:
Think it's ready to go. Leaving it for a bit in case you have some input!
Works perfectly for me :+1:
Is there a keybind to navigate between sections directly? Right now I'm working around it by collapsing then navigating up/down. But it'd be nice if there's a direct keybind for it.
For reference here are the keybind magit uses for section navigation: https://magit.vc/manual/magit/Section-Movement.html