mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Move the click-path hyperlink lookup onto View
Reading a view's internal buffer belongs on the view itself, next to findHyperlinkAt, rather than in the event loop; and the view is where the lock that guards that buffer can be taken. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d65ee95942
commit
e3fe321080
|
|
@ -1763,10 +1763,8 @@ func (g *Gui) onKey(ev *GocuiEvent) error {
|
|||
}
|
||||
|
||||
if ev.Key.KeyName() == MouseLeft && (ev.Key.Mod()&ModMotion) == 0 && !v.Editable && g.openHyperlink != nil {
|
||||
if newY >= 0 && newY <= len(v.viewLines)-1 && newX >= 0 && newX <= len(v.viewLines[newY].line)-1 {
|
||||
if link := v.viewLines[newY].line[newX].hyperlink; link != "" {
|
||||
return g.openHyperlink(link, v.name)
|
||||
}
|
||||
if link := v.hyperlinkAt(newX, newY); link != "" {
|
||||
return g.openHyperlink(link, v.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2116,6 +2116,16 @@ func (v *View) onMouseMove(x int, y int) {
|
|||
}
|
||||
}
|
||||
|
||||
// hyperlinkAt returns the hyperlink at the given position of the view's
|
||||
// content, or an empty string if there is none.
|
||||
func (v *View) hyperlinkAt(x, y int) string {
|
||||
if y < 0 || y >= len(v.viewLines) || x < 0 || x >= len(v.viewLines[y].line) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return v.viewLines[y].line[x].hyperlink
|
||||
}
|
||||
|
||||
func (v *View) findHyperlinkAt(x, y int) *SearchPosition {
|
||||
linkStr := v.viewLines[y].line[x].hyperlink
|
||||
if linkStr == "" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue