commit fea02b0bf5e8d28eb46dd51dc411aa2836905b1f from: Omar Polo date: Wed Apr 13 19:59:33 2022 UTC don't highlight the first completion by deafult This is the first commit of a series to improve the handling of completions. Currently it's a mess: some commands look at the selected entry, others at what was typed in the minibuffer... it's not clear which commands does what. So, change of defaults: don't highlight anything by default to avoid confusing the user, C-n and C-p now are the obvious way to move the focus from the minibuffer to a completion. This doesn't change how the commands handle the selection, that will done in a follow-up commit. commit - 69980762e94af37ac9930afe1f00af0bef6cad37 commit + fea02b0bf5e8d28eb46dd51dc411aa2836905b1f blob - b208291f42a1cd30436808fbdff5f93802ce7063 blob + ccb571e9dca92633ca0afe9be381a797156e874d --- cmd.c +++ cmd.c @@ -828,13 +828,13 @@ cmd_previous_completion(struct buffer *buffer) return; buffer = &ministate.compl.buffer; + if (buffer->current_line == NULL) + return; - if (buffer->current_line != NULL) + buffer->current_line->parent->type = LINE_COMPL; + if (!forward_line(buffer, -1)) buffer->current_line->parent->type = LINE_COMPL; - - forward_line(buffer, -1); - - if (buffer->current_line != NULL) + else buffer->current_line->parent->type = LINE_COMPL_CURRENT; } @@ -845,12 +845,14 @@ cmd_next_completion(struct buffer *buffer) return; buffer = &ministate.compl.buffer; + if (buffer->current_line == NULL) + return; - if (buffer->current_line != NULL) + if (buffer->current_line->parent->type == LINE_COMPL_CURRENT) { buffer->current_line->parent->type = LINE_COMPL; + forward_line(buffer, +1); + } - forward_line(buffer, +1); - if (buffer->current_line != NULL) buffer->current_line->parent->type = LINE_COMPL_CURRENT; } blob - d303e21303f76bf05163e3830d131ac8c87c551c blob + db9b9cb21f66e7045e98eebe15d92d97f935db9b --- minibuffer.c +++ minibuffer.c @@ -91,7 +91,6 @@ recompute_completions(int add) char *input, **ap, *words[10]; size_t len = 0; struct line *l; - struct vline *vl; struct buffer *b; if (in_minibuffer != MB_COMPREAD) @@ -126,9 +125,6 @@ recompute_completions(int add) if (b->current_line == NULL) b->current_line = TAILQ_FIRST(&b->head); b->current_line = adjust_line(b->current_line, b); - vl = b->current_line; - if (vl != NULL) - vl->parent->type = LINE_COMPL_CURRENT; } int @@ -475,9 +471,6 @@ populate_compl_buffer(complfn *fn, void *data) linedata = NULL; descr = NULL; } - - if ((l = TAILQ_FIRST(&p->head)) != NULL) - l->type = LINE_COMPL_CURRENT; } void