Skip to content

fix(completions): init emoji once in CAPF setup#569

Merged
zevlg merged 1 commit into
zevlg:masterfrom
liaowang11:fix/emoji-capf-init-before-search
Apr 16, 2026
Merged

fix(completions): init emoji once in CAPF setup#569
zevlg merged 1 commit into
zevlg:masterfrom
liaowang11:fix/emoji-capf-init-before-search

Conversation

@liaowang11
Copy link
Copy Markdown
Contributor

@liaowang11 liaowang11 commented Apr 14, 2026

Summary

The re-search-backward in the emoji CAPF functions uses telega-emoji-candidate-max-length as the search bound:

(re-search-backward "\\(?:^\\|[[:space:]]\\)\\(:[^: _]+\\)"
  (max (point-min) (- end telega-emoji-candidate-max-length)) t)

When telega-emoji-candidate-max-length is 0 (before init), the bound collapses to end, leaving no range to search backward — so the regex never matches, the when-let* falls through, and telega-emoji-init (previously inside the match block) is never reached.

Move the init call to telega-completions-setup-capf, where it runs once at chat buffer setup time, only when an emoji CAPF function is present in telega-completions-capf-functions.

Test plan

  • All 20 existing tests pass including new emoji CAPF tests
  • CI passes on both Emacs 28.1 and snapshot
  • Verify emoji completion works in a chat buffer with CAPF
  • Verify emoji completion still works with company backend

@liaowang11 liaowang11 changed the title fix(completions): init emoji in CAPF setup, not per-invocation fix(completions): init emoji once in CAPF setup Apr 14, 2026
Comment thread telega-completions.el
Comment thread telega-completions.el Outdated
@liaowang11 liaowang11 force-pushed the fix/emoji-capf-init-before-search branch from a5f2bec to bf94b8e Compare April 15, 2026 13:50
@zevlg zevlg merged commit 5196e75 into zevlg:master Apr 16, 2026
2 checks passed
@zevlg
Copy link
Copy Markdown
Owner

zevlg commented Apr 16, 2026

Merged in, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants