diff --git a/functions/config_help.fish b/functions/config_help.fish index 7bbf085..814a6a9 100644 --- a/functions/config_help.fish +++ b/functions/config_help.fish @@ -34,9 +34,22 @@ function config_help --description 'Open the offline fish shell configuration ma end # ── Resolve section start line ─────────────────────────────── + # Normalize both sides: strip non-alphanumeric chars and lowercase. + # This lets "keybindings" match "KEY BINDINGS", "fish-deps" match + # "fish-deps", etc. without requiring exact punctuation or case. set -l start_line 1 if test -n "$argv[1]" - set -l found (grep -n -im 1 "^#\+.*$argv[1]" "$doc_file" | cut -d: -f1) + set -l norm_kw (string lower -- $argv[1] | string replace -ra '[^a-z0-9]' '') + set -l found "" + for entry in (grep -n "^#" "$doc_file") + set -l lnum (string split -f 1 ':' -- $entry) + set -l text (string split -f 2- ':' -- $entry) + set -l norm_text (string lower -- $text | string replace -ra '[^a-z0-9]' '') + if string match -q "*$norm_kw*" $norm_text + set found $lnum + break + end + end if test -n "$found" set start_line $found else