about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-07-13 23:17:35 +0100
committerJames Booth <boothj5@gmail.com>2013-07-13 23:17:35 +0100
commit60cad8d29631443a5787b2052dd22716b284ee35 (patch)
tree969db1ee0d7854d792f6e2c71842fd527f88be01
parentbb550fed5547c7885e3f9c486051c742ac0b9b67 (diff)
parent1d05a7047314fa3c669358114dc6ce36bbc08386 (diff)
downloadprofani-tty-60cad8d29631443a5787b2052dd22716b284ee35.tar.gz
Merge branch 'master' into unicode
-rw-r--r--src/tools/history.c4
-rw-r--r--src/ui/inputwin.c4
-rw-r--r--tests/test_history.c6
3 files changed, 11 insertions, 3 deletions
diff --git a/src/tools/history.c b/src/tools/history.c
index 5ac41969..b80a9555 100644
--- a/src/tools/history.c
+++ b/src/tools/history.c
@@ -146,6 +146,10 @@ history_next(History history, char *item)
         return NULL;
     }
 
+    if (g_list_next(history->session.sess_curr) == NULL) {
+        return NULL;
+    }
+
     char *copied = "";
     if (item != NULL) {
         copied = strdup(item);
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 3f3d2ab5..feb4a0ba 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -490,6 +490,10 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
             next = cmd_history_next(input, size);
             if (next) {
                 inp_replace_input(input, next, size);
+            } else if (*size != 0) {
+                input[*size] = '\0';
+                cmd_history_append(input);
+                inp_replace_input(input, "", size);
             }
             return 1;
 
diff --git a/tests/test_history.c b/tests/test_history.c
index 91e5aa99..6af96946 100644
--- a/tests/test_history.c
+++ b/tests/test_history.c
@@ -93,7 +93,7 @@ void prev_with_val_then_next_returns_val(void)
     assert_string_equals("Oioi", item2);
 }
 
-void prev_with_val_then_next_twice_returns_val(void)
+void prev_with_val_then_next_twice_returns_null(void)
 {
     History history = history_new(10);
     history_append(history, "Hello");
@@ -102,7 +102,7 @@ void prev_with_val_then_next_twice_returns_val(void)
     char *item2 = history_next(history, item1);
     char *item3 = history_next(history, item2);
 
-    assert_string_equals("Oioi", item3);
+    assert_is_null(item3);
 }
 
 void navigate_then_append_new(void)
@@ -225,7 +225,7 @@ void register_history_tests(void)
     TEST(previous_goes_to_correct_element);
     TEST(prev_then_next_returns_empty);
     TEST(prev_with_val_then_next_returns_val);
-    TEST(prev_with_val_then_next_twice_returns_val);
+    TEST(prev_with_val_then_next_twice_returns_null);
     TEST(navigate_then_append_new);
     TEST(edit_item_mid_history);
     TEST(edit_previous_and_append);