From 41e801eab15354fe887978ff9cf1b2a8aaf4d599 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 6 Jun 2026 03:35:34 -0400 Subject: [PATCH] fix(config_help): jump to section heading via psub + --jump-target --pattern matched the first textual occurrence of the keyword anywhere in the document. Replace with psub to make bat's output seekable, then use --jump-target with the line number resolved by grep against heading lines only (^#+.*keyword), so keyword jumps land on the actual section header rather than an example or body reference. --- functions/config_help.fish | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/functions/config_help.fish b/functions/config_help.fish index a25bd27..7bbf085 100644 --- a/functions/config_help.fish +++ b/functions/config_help.fish @@ -51,27 +51,25 @@ function config_help --description 'Open the offline fish shell configuration ma # bat emits: ESC[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. + # psub creates a seekable temp file so --jump-target works on bat output. 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]" + if test $start_line -gt 1 + set -a ov_args --jump-target $start_line end - bat --color=always --style=plain --language=markdown "$doc_file" \ - | ov $ov_args + ov $ov_args (bat --color=always --style=plain --language=markdown "$doc_file" | psub) # ov alone: section navigation on raw Markdown; no code highlighting. else if type -q ov set -l ov_args \ --section-delimiter "^#" \ - --section-header \ - "$doc_file" - if test -n "$argv[1]" - set -a ov_args --pattern "$argv[1]" + --section-header + if test $start_line -gt 1 + set -a ov_args --jump-target $start_line end - ov $ov_args + ov $ov_args "$doc_file" # bat alone: syntax highlighting with built-in paging; no line jump. else if type -q bat