From: Daniel Carl Date: Sat, 29 Jun 2013 21:01:34 +0000 (+0200) Subject: Fixed broken completion for long uri (#39). X-Git-Url: https://git.owens.tech/assets/static/git-favicon.png/assets/static/git-favicon.png/git?a=commitdiff_plain;h=9c7171e2daa79ef9f3cfe4ef68c63dba4c280e03;p=vimb.git Fixed broken completion for long uri (#39). 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. --- diff --git a/src/bookmark.c b/src/bookmark.c index 0c05b2c..7a38ad9 100644 --- a/src/bookmark.c +++ b/src/bookmark.c @@ -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"))) { diff --git a/src/completion.c b/src/completion.c index 18cd73f..2e38480 100644 --- a/src/completion.c +++ b/src/completion.c @@ -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); diff --git a/src/history.c b/src/history.c index 13f6521..dcdd853 100644 --- a/src/history.c +++ b/src/history.c @@ -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"))) { diff --git a/src/main.c b/src/main.c index db76863..5bd4804 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/main.h b/src/main.h index 9904a65..464b371 100644 --- a/src/main.h +++ b/src/main.h @@ -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