summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/completions.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/completions.c b/src/completions.c
index 314bd23..1347e7c 100644
--- a/src/completions.c
+++ b/src/completions.c
@@ -136,6 +136,13 @@ completions_complete (rp_completions *c, char *partial, int direction)
if (c->last_match == NULL)
return NULL;
+ /* c->last_match contains the first match in the forward
+ direction. So if we're looking for the previous match, then
+ check the previous element from last_match. */
+ if (direction == COMPLETION_PREVIOUS)
+ c->last_match = list_prev_entry (c->last_match, &c->completion_list, node);
+
+ /* Now check if last_match is a match for partial. */
if (str_comp (sbuf_get (c->last_match), c->partial, strlen (c->partial)))
return sbuf_get (c->last_match);
}