fix(config_help): use --pattern for section jump; correct ov nav keys

--jump-target does not work reliably on piped stdin. Replace with
--pattern which positions ov at the first occurrence of the keyword
(works like less +/pattern) and keeps the match highlighted so the
user can press n/N to navigate further occurrences.

Also correct the section navigation keys in the offline manual:
  Space = next section  (not '.')
  ^     = previous section  (not ',')
  Alt+u = section list sidebar
This commit is contained in:
2026-06-06 03:29:14 -04:00
parent 1a752c4c87
commit 490834e6f9
2 changed files with 30 additions and 13 deletions
+10 -1
View File
@@ -1216,7 +1216,16 @@ calls fisher update as its first step.
config_help
ov renders the Markdown with syntax highlighting and section-based
navigation. Use , and . to jump between sections. Press / to search.
navigation.
Space next section
^ previous section
Alt+u toggle section list sidebar
/ search forward
n / N next / previous search match
g go to line number
j interactive jump target (line, %, or 'section')
q quit
## With bat
+20 -12
View File
@@ -47,23 +47,31 @@ function config_help --description 'Open the offline fish shell configuration ma
end
# ── Viewer fallback chain ────────────────────────────────────
# Best case: bat colors the output; ov matches headers in the ANSI stream
# via a regex that skips the escape codes preceding each '#'.
# bat emits headers as: ESC[<color>m# ... so we match ^(ESC\[[0-9;]*m)+#
# This is theme-agnostic (works for any 8/24-bit color sequence) and
# gives us both syntax highlighting AND section navigation (,/.).
# bat colors the output; ov matches headers via an ANSI-aware regex.
# bat emits: ESC[<color>m# ... so delimiter ^(\x1b\[[0-9;]*m)+# matches
# any 8/24-bit color sequence before a '#', theme-agnostic.
# Section nav: Space (next), ^ (previous), Alt+u (section list sidebar).
# Keyword jump uses --pattern which positions at the first search match.
if type -q ov; and type -q bat
set -l ov_args \
--section-delimiter "^(\x1b\[[0-9;]*m)+#" \
--section-header
if test -n "$argv[1]"
set -a ov_args --pattern "$argv[1]"
end
bat --color=always --style=plain --language=markdown "$doc_file" \
| ov --section-delimiter "^(\x1b\[[0-9;]*m)+#" \
--section-header \
--jump-target "$start_line"
| ov $ov_args
# ov alone: section navigation on raw Markdown; no code highlighting.
else if type -q ov
ov --section-delimiter "^#" \
--section-header \
--jump-target "$start_line" \
"$doc_file"
set -l ov_args \
--section-delimiter "^#" \
--section-header \
"$doc_file"
if test -n "$argv[1]"
set -a ov_args --pattern "$argv[1]"
end
ov $ov_args
# bat alone: syntax highlighting with built-in paging; no line jump.
else if type -q bat