summaryrefslogtreecommitdiff
path: root/src/completion.c
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2015-11-22 22:30:05 +0100
committerDaniel Carl <danielcarl@gmx.de>2015-11-22 22:34:59 +0100
commitea35b8e9d23356bef0b75b67f1f45f08bae60717 (patch)
treecd4b3b9a3e1d2715af8677d7a30018d0b1a09536 /src/completion.c
parent47db985493dcf10ebd4c6d2830ef34958295682e (diff)
Use sorting for completion by default.
This makes the codes easeir to read, because the most completions should be sorted.
Diffstat (limited to 'src/completion.c')
-rw-r--r--src/completion.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/completion.c b/src/completion.c
index d90ed17..a15b081 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -174,24 +174,26 @@ gboolean completion_next(gboolean back)
rows = gtk_tree_model_iter_n_children(gtk_tree_view_get_model(tree), NULL);
if (back) {
- /* step back */
- if (--comp.active < 0) {
- if (comp.active == -1) {
- gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(comp.tree)));
- return false;
- } else {
- comp.active = rows - 1;
- }
+ comp.active--;
+ /* Step back over the beginning. */
+ if (comp.active == -1) {
+ /* Unselect the current item to show the user that the shown
+ * content is the initial typed content. */
+ gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(comp.tree)));
+
+ return false;
+ } else if (comp.active < -1) {
+ comp.active = rows - 1;
}
} else {
- /* step forward */
- if (++comp.active >= rows) {
- if (comp.active == rows) {
- gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(comp.tree)));
- return false;
- } else {
- comp.active = 0;
- }
+ comp.active++;
+ /* Step over the end. */
+ if (comp.active == rows) {
+ gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(comp.tree)));
+
+ return false;
+ } else if (comp.active >= rows) {
+ comp.active = 0;
}
}