Merge branch 'zero-lines'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Closes #92
authored by Daniel Eklöf · committed by Daniel Eklöf · parents aa456b7, 20940f2 · Browse files · 2 files·+15 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+15 added−11 removed
- other:+15 added−11 removed
Provenance
- Commit
fa1bd98- Tree
48cc0cf- Author
Daniel Eklöf <daniel@ekloef.se>- Committer
Daniel Eklöf <daniel@ekloef.se>- Parent 1
aa456b7- Parent 2
20940f2
2 files changed+15 added−11 removed
modified:CHANGELOG.md+2 added
67 unmodified lines68 * Tab and Shift+Tab not wrapping around69 (https://codeberg.org/dnkl/fuzzel/issues/78).70 * Visual glitches in the corners, when using rounded corners71 (https://codeberg.org/dnkl/fuzzel/issues/90).72+* Regression: `--dmenu --lines=0` crashing73+ (https://codeberg.org/dnkl/fuzzel/issues/92).74 75 76 ### Security77 ### Contributors227 unmodified linesmodified:match.c+13 added-11 removed
217 unmodified lines218 matches_get_page_count(const struct matches *matches)219 {220 return matches->max_matches_per_page != 0221 ? matches->match_count / matches->max_matches_per_page222- : 0;222+ : matches->match_count;223 }224 225 size_t226 matches_get_page(const struct matches *matches)227 {228 return matches->max_matches_per_page != 0229 ? matches->selected / matches->max_matches_per_page230- : 0;230+ : matches->selected;231 }232 233 const struct match *234 matches_get(const struct matches *matches, size_t idx)27 unmodified lines262 {263 const size_t total = matches->match_count;264 const size_t page_no = matches_get_page(matches);265 266+ if (matches->max_matches_per_page == 0)267+ return 0;268+269 if (total == 0)270 return 0;271 else if (page_no + 1 >= matches->page_count) {272 size_t remainder = total % matches->max_matches_per_page;129 unmodified lines402 403 void404 matches_update(struct matches *matches, const struct prompt *prompt)405 {403- assert(matches->max_matches_per_page > 0);404-406 if (matches->applications == NULL)407 return;408 409 const wchar_t *ptext = prompt_text(prompt);16 unmodified lines426 427 if (matches->selected >= matches->match_count && matches->selected > 0)428 matches->selected = matches->match_count - 1;429 429- matches->page_count = (430- matches->match_count + (matches->max_matches_per_page - 1)) /431- matches->max_matches_per_page;432-430+ matches->page_count = matches->max_matches_per_page > 0431+ ? ((matches->match_count + (matches->max_matches_per_page - 1)) /432+ matches->max_matches_per_page)433+ : 1;434 return;435 }436 437 const enum match_fields fields = matches->fields;123 unmodified lines561 562 /* Sort */563 qsort(matches->matches, matches->match_count, sizeof(matches->matches[0]), &match_compar);564 564- matches->page_count = (565- matches->match_count + (matches->max_matches_per_page - 1)) /566- matches->max_matches_per_page;565+ matches->page_count = matches->max_matches_per_page566+ ? ((matches->match_count + (matches->max_matches_per_page - 1)) /567+ matches->max_matches_per_page)568+ : 1;569 570 if (matches->selected >= matches->match_count && matches->selected > 0)571 matches->selected = matches->match_count - 1;572 }