dmenu: fix --index desync when an input entry is dropped
Before adoption: this commit came in with the history the project adopted, so no landing records it.
dmenu_load_entries() skips any stdin entry that fails ambstoc32() (e.g. invalid multibyte data) via a bare `continue`, without advancing app_idx. Since app_idx becomes the entry's app->index -- the value --dmenu --index later prints for whatever gets selected -- every entry after a dropped one ends up with an index that is too low by the number of entries dropped before it. This is easy to trigger in practice: any upstream producer that truncates preview text to a fixed byte length (cliphist does this) can slice a multi-byte UTF-8 character in half, producing one invalid entry partway down the list. From that point on, clicking or otherwise selecting an entry and asking fuzzel to --index it back resolves to the wrong line -- fuzzel's own selection state is correct (confirmed by instrumenting execute_selected() and dmenu_execute() directly: both agree on the intended entry's title), but the index handed back to the caller points one row short of it, so the caller ends up acting on an unrelated entry instead. Fix: advance app_idx on the dropped-entry path too, so the counter always reflects each entry's true ordinal position in the original input, independent of whether that particular entry made it into the visible list. Verified with `--auto-select --search=...` against a captured real-world input containing one entry with a truncated (invalid) UTF-8 preview: index printed for the entry two rows below it went from 40 (wrong; the deleted entry's own would-be index) to 41 (correct, matching its actual 0-based stdin line number).
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+20 added−0 removed
- other:+20 added−0 removed