Skip to content

Sly's cached completion table list is being destructively modified by Corfu #557

@lapinskim

Description

@lapinskim

With Corfu enabled in common-lisp mode when completing at point, when the first candidate is equal to prompt, Corfu errors out with:
Error in post-command-hook (corfu--post-command): (args-out-of-range 0 0).

This can be observed simply by trying to complete after car or not

I tracked this to the function corfu--move-to-front which uses delq on the list which references the cached Sly's completion table, effectively setting the first element to nil. See minad/corfu#285 for the reference.

As Corfu's maintainer kindly pointed out in the above mentioned issue, this seems to be the default Emacs behavior, that returned completion list can be destructively modified by a completion UI. For reference, this can be seen in the function completion-all-sorted-completions in minibuffer.el:
https://github.com/emacs-mirror/emacs/blob/15fc7b3cde92e420f48dfe188251e6af4d832af5/lisp/minibuffer.el#L1640-L1661

The easiest solution might be to return a copy of the cached completion candidate list.

Thank you for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions