Fixed broken completion for long uri (#39).
authorDaniel Carl <danielcarl@gmx.de>
Sat, 29 Jun 2013 21:01:34 +0000 (23:01 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 29 Jun 2013 21:13:04 +0000 (23:13 +0200)
If the completion reached a uri that where longer than 255 chars the
completion reduced to one possible item. The reason was the vb_echo* functions
that used only 255 chars to put into inputbox. If the uri was longer we
considered the current text and the text of completion item as different and
cleaned the completion and created a new list with the current text of 255
chars which normally matched only once.

The buffer size is now set to 512 for all internal used string buffer.

src/bookmark.c
src/completion.c
src/history.c
src/main.c
src/main.h

index 0c05b2c..7a38ad9 100644 (file)
@@ -93,7 +93,7 @@ static GList *load(const char *file)
 {
     /* read the items from file */
     GList *list   = NULL;
-    char buf[512] = {0};
+    char buf[BUF_SIZE] = {0};
     FILE *f;
 
     if (!(f = fopen(file, "r"))) {
index 18cd73f..2e38480 100644 (file)
@@ -243,9 +243,6 @@ static void move_cursor(gboolean back)
         }
     }
 
-    while (gtk_events_pending()) {
-        gtk_main_iteration();
-    }
     /* get new path and move cursor to it */
     path = gtk_tree_path_new_from_indices(comp.active, -1);
     gtk_tree_view_set_cursor(tree, path, NULL, false);
index 13f6521..dcdd853 100644 (file)
@@ -209,7 +209,7 @@ static GList *load(const char *file)
 {
     /* read the history items from file */
     GList *list   = NULL;
-    char buf[512] = {0};
+    char buf[BUF_SIZE] = {0};
     FILE *f;
 
     if (!(f = fopen(file, "r"))) {
index db76863..5bd4804 100644 (file)
@@ -77,11 +77,11 @@ static void inputbox_print(gboolean force, const MessageType type, gboolean hide
 
 void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...)
 {
-    char message[255];
+    char message[BUF_SIZE];
     va_list arg_list;
 
     va_start(arg_list, error);
-    vsnprintf(message, 255, error, arg_list);
+    vsnprintf(message, BUF_SIZE, error, arg_list);
     va_end(arg_list);
 
     inputbox_print(true, type, hide, message);
@@ -89,11 +89,11 @@ void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...
 
 void vb_echo(const MessageType type, gboolean hide, const char *error, ...)
 {
-    char message[255];
+    char message[BUF_SIZE];
     va_list arg_list;
 
     va_start(arg_list, error);
-    vsnprintf(message, 255, error, arg_list);
+    vsnprintf(message, BUF_SIZE, error, arg_list);
     va_end(arg_list);
 
     inputbox_print(false, type, hide, message);
index 9904a65..464b371 100644 (file)
@@ -33,6 +33,9 @@
 #else
 #endif
 
+/* size of some I/O buffer */
+#define BUF_SIZE  512
+
 #define LENGTH(x) (sizeof x / sizeof x[0])
 
 #ifdef DEBUG