mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-21 15:44:17 +02:00
enh: visit nearest available link by default
This commit is contained in:
parent
cf1a50c7a6
commit
fe7986f6c8
1 changed files with 10 additions and 0 deletions
10
ui/pager.go
10
ui/pager.go
|
|
@ -254,6 +254,16 @@ func (m pagerModel) update(msg tea.Msg) (pagerModel, tea.Cmd) {
|
|||
return m, cmd
|
||||
}
|
||||
if len(m.links) > 0 {
|
||||
// No link selected. Just visit the nearest visible link.
|
||||
body := strings.TrimSpace(m.currentDocument.Body)
|
||||
for i, l := range m.links {
|
||||
if strings.Contains(body, l.Label) {
|
||||
m.focusedLink = i
|
||||
cmd := m.followFocusedLink()
|
||||
return m, cmd
|
||||
}
|
||||
}
|
||||
|
||||
cmds = append(cmds, m.showStatusMessage(pagerStatusMessage{"Tab to select a link", false}))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue