1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-03 00:57:52 +02:00

Press enter in main view of files/commitFiles to enter staging/patch-building

This was already possible, but only when a file was selected, and it woudln't
always land on the right line when a pager was used. Now it's also possible to
do this for directories, and it jumps to the right line.

At the moment this is a hack that relies on delta's hyperlinks, so it only works
on lines that have hyperlinks (added and context).

The implementation is very hacky for other reasons too (e.g. the addition of the
weirdly named ClickedViewRealLineIdx to OnFocusOpts).
This commit is contained in:
Stefan Haller
2024-09-16 20:38:22 +02:00
parent f827945cab
commit cbeca72bae
10 changed files with 155 additions and 20 deletions

View File

@ -1470,6 +1470,20 @@ func (v *View) Word(x, y int) (string, bool) {
return str[nl:nr], true
}
func (v *View) HyperLinkInLine(y int, urlScheme string) (string, bool) {
if y < 0 || y >= len(v.viewLines) {
return "", false
}
for _, c := range v.lines[v.viewLines[y].linesY] {
if strings.HasPrefix(c.hyperlink, urlScheme) {
return c.hyperlink, true
}
}
return "", false
}
// indexFunc allows to split lines by words taking into account spaces
// and 0.
func indexFunc(r rune) bool {