| ... | ... |
@@ -72,8 +72,9 @@ static void draw(tty_interface_t *state) {
|
| 72 | 72 |
size_t current_selection = choices->selection; |
| 73 | 73 |
if (current_selection + options->scrolloff >= num_lines) {
|
| 74 | 74 |
start = current_selection + options->scrolloff - num_lines + 1; |
| 75 |
- if (start + num_lines >= choices_available(choices)) {
|
|
| 76 |
- start = choices_available(choices) - num_lines; |
|
| 75 |
+ size_t available = choices_available(choices); |
|
| 76 |
+ if (start + num_lines >= available && available > 0) {
|
|
| 77 |
+ start = available - num_lines; |
|
| 77 | 78 |
} |
| 78 | 79 |
} |
| 79 | 80 |
tty_setcol(tty, 0); |
| ... | ... |
@@ -87,7 +88,9 @@ static void draw(tty_interface_t *state) {
|
| 87 | 88 |
draw_match(state, choice, i == choices->selection); |
| 88 | 89 |
} |
| 89 | 90 |
} |
| 90 |
- tty_moveup(tty, num_lines); |
|
| 91 |
+ if (num_lines > 0) {
|
|
| 92 |
+ tty_moveup(tty, num_lines); |
|
| 93 |
+ } |
|
| 91 | 94 |
tty_setcol(tty, strlen(options->prompt) + strlen(state->search)); |
| 92 | 95 |
tty_flush(tty); |
| 93 | 96 |
} |