sigil-docs: remove stale local keyword->string shadows
(sigil docs search) and (sigil docs index) each defined a local keyword->string that did (symbol->string kw) and stripped the trailing colon. That treated keywords as symbols ending in ':', but modern Sigil keywords are their own type -- (symbol->string kw) signals "symbol->string: expected symbol" immediately. The shadow shadowed the native (sigil core) keyword->string imported via the module's import list, so every search-docs call errored on the first key.
Because the iteration was inside a silent filter-map, errors were swallowed and callers just saw empty results -- hiding the bug for as long as the docs JSON files were empty (they always were, see the preceding compiler.c fix). Now that the JSON has real content and search-docs actually runs the filter-map body, the shadow surfaced.
Deleting both local definitions makes keyword->string resolve to the (sigil core) native, which handles Sigil keywords correctly.
After this: (search-docs "json-encode") returns 1 hit (json-encode in (sigil json)), unblocking hover/completion/ suggest-import in sigil-lsp and sigil-mcp.
src/sigil/docs/index.sgl | 8 --------
src/sigil/docs/search.sgl | 49 ++++++++++++++++++++++++++++---------------------
2 files changed, 28 insertions(+), 29 deletions(-)src/sigil/docs/index.sglmodified
(begin ;; Convert keyword to string (remove trailing colon) (define (keyword->string kw) (let ((s (symbol->string kw))) (if (and (> (string-length s) 0) (char=? (string-ref s (- (string-length s) 1)) #\:)) (substring s 0 (- (string-length s) 1)) s))) ;; Extract first line of a string for summary (define (first-line str) (if (or (not str) (not (string? str)))src/sigil/docs/search.sglmodified
(matches? word str))) words))) ;; Coerce a dict key to its string form. The symbol index is keyed by ;; keywords, but we accept strings/symbols defensively too. (define (key->string k) (cond ((keyword? k) (keyword->string k)) ((symbol? k) (symbol->string k)) ((string? k) k) (else #f))) ;; Search symbols in the index (define (search-symbols index query) (let ((symbols (dict-ref index symbols: #{}))) (filter-map (lambda (key) (let* ((info (dict-ref symbols key #f)) (name (keyword->string key)) (module (dict-ref info module: "")) (lambda (key) (search-symbols-one symbols key query)) (dict-keys symbols)))) (define (search-symbols-one symbols key query) (guard (e (else #f)) (let ((info (dict-ref symbols key #f)) (name (key->string key))) (cond ((or (not name) (not info)) #f) (else (let ((module (dict-ref info module: "")) (kind (dict-ref info kind: "unknown")) (summary (dict-ref info summary: ""))) ;; Match on name or summary (if (or (any-word-matches? query name) (any-word-matches? query summary)) (search-result name: name module: module kind: kind summary: summary) #f))) (dict-keys symbols)))) (if (or (any-word-matches? query name) (and (string? summary) (any-word-matches? query summary))) (search-result name: name module: (if (string? module) module "") kind: (if (string? kind) kind "unknown") summary: (if (string? summary) summary "")) #f))))))) ;; Filter results by module if specified (define (filter-by-module results module-filter) ((pred (car lst)) #t) (else (any pred (cdr lst))))) ;; Convert keyword to string (remove trailing colon) (define (keyword->string kw) (let ((s (symbol->string kw))) (if (and (> (string-length s) 0) (char=? (string-ref s (- (string-length s) 1)) #\:)) (substring s 0 (- (string-length s) 1)) s))) ))