From 63fc4bb6be87e9e3334958b991be9ad9d3f9aa7e Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 6 Jun 2026 03:39:53 -0400 Subject: [PATCH] fix(config_help): normalize keyword and heading before matching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous grep pattern required an exact substring match, so "keybindings" failed to match the heading "KEY BINDINGS". Normalize both the user keyword and each heading line by stripping all non-alphanumeric characters and lowercasing before comparing, so "keybindings" → "keybindings" matches "KEY BINDINGS" → "keybindings", "fish-deps" matches "fish-deps", etc. --- functions/config_help.fish | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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