diff options
-rw-r--r-- | src/common/completion.c | 5 | ||||
-rw-r--r-- | src/common/completion.h | 1 | ||||
-rw-r--r-- | src/gui/gui-common.c | 17 | ||||
-rw-r--r-- | weechat/src/common/completion.c | 5 | ||||
-rw-r--r-- | weechat/src/common/completion.h | 1 | ||||
-rw-r--r-- | weechat/src/gui/gui-common.c | 17 |
6 files changed, 32 insertions, 14 deletions
diff --git a/src/common/completion.c b/src/common/completion.c index 0896e04b4..b065ae8dc 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -66,6 +66,7 @@ completion_init (t_completion *completion, void *server, void *channel) completion->position = -1; completion->args = NULL; completion->direction = 0; + completion->add_space = 1; completion->completion_list = NULL; completion->last_completion = NULL; @@ -297,6 +298,8 @@ completion_list_add_filename (t_completion *completion) int in_user_home = 0; char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' }; + completion->add_space = 0; + if ((strncmp (completion->base_word, home, 2) == 0) && getenv("HOME")) in_user_home = 1; else if ((strncmp (completion->base_word, DIR_SEPARATOR, 1) != 0) @@ -1025,6 +1028,7 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p /* look for context */ completion_free (completion); + completion->add_space = 1; command = ((buffer[0] == '/') && (buffer[1] != '/')) ? 1 : 0; command_arg = 0; i = 0; @@ -1546,6 +1550,7 @@ completion_print_log (t_completion *completion) weechat_log_printf (" position . . . . . . . : %d\n", completion->position); weechat_log_printf (" args . . . . . . . . . : '%s'\n", completion->args); weechat_log_printf (" direction. . . . . . . : %d\n", completion->direction); + weechat_log_printf (" add_space. . . . . . . : %d\n", completion->add_space); weechat_log_printf (" completion_list. . . . : 0x%X\n", completion->completion_list); weechat_log_printf (" last_completion. . . . : 0x%X\n", completion->last_completion); weechat_log_printf (" word_found . . . . . . : '%s'\n", completion->word_found); diff --git a/src/common/completion.h b/src/common/completion.h index c65d7ce0d..b6e4e735e 100644 --- a/src/common/completion.h +++ b/src/common/completion.h @@ -44,6 +44,7 @@ struct t_completion int position; /* position where Tab was pressed */ char *args; /* command line args (including base word) */ int direction; /* +1 = search next word, -1 = previous word */ + int add_space; /* add space after completion? */ /* for command argument completion */ t_weelist *completion_list; /* data list for completion */ diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index d15ae2e29..424ae94e7 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -628,13 +628,16 @@ gui_input_complete (t_gui_window *window) if ((window->buffer->completion.context == COMPLETION_COMMAND) || (window->buffer->completion.context == COMPLETION_COMMAND_ARG)) { - if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer, - window->buffer->input_buffer_pos)] != ' ') - gui_insert_string_input (window, " ", - window->buffer->input_buffer_pos); - if (window->buffer->completion.position >= 0) - window->buffer->completion.position++; - window->buffer->input_buffer_pos++; + if (window->buffer->completion.add_space) + { + if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer, + window->buffer->input_buffer_pos)] != ' ') + gui_insert_string_input (window, " ", + window->buffer->input_buffer_pos); + if (window->buffer->completion.position >= 0) + window->buffer->completion.position++; + window->buffer->input_buffer_pos++; + } } else { diff --git a/weechat/src/common/completion.c b/weechat/src/common/completion.c index 0896e04b4..b065ae8dc 100644 --- a/weechat/src/common/completion.c +++ b/weechat/src/common/completion.c @@ -66,6 +66,7 @@ completion_init (t_completion *completion, void *server, void *channel) completion->position = -1; completion->args = NULL; completion->direction = 0; + completion->add_space = 1; completion->completion_list = NULL; completion->last_completion = NULL; @@ -297,6 +298,8 @@ completion_list_add_filename (t_completion *completion) int in_user_home = 0; char home[3] = { '~', DIR_SEPARATOR_CHAR, '\0' }; + completion->add_space = 0; + if ((strncmp (completion->base_word, home, 2) == 0) && getenv("HOME")) in_user_home = 1; else if ((strncmp (completion->base_word, DIR_SEPARATOR, 1) != 0) @@ -1025,6 +1028,7 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p /* look for context */ completion_free (completion); + completion->add_space = 1; command = ((buffer[0] == '/') && (buffer[1] != '/')) ? 1 : 0; command_arg = 0; i = 0; @@ -1546,6 +1550,7 @@ completion_print_log (t_completion *completion) weechat_log_printf (" position . . . . . . . : %d\n", completion->position); weechat_log_printf (" args . . . . . . . . . : '%s'\n", completion->args); weechat_log_printf (" direction. . . . . . . : %d\n", completion->direction); + weechat_log_printf (" add_space. . . . . . . : %d\n", completion->add_space); weechat_log_printf (" completion_list. . . . : 0x%X\n", completion->completion_list); weechat_log_printf (" last_completion. . . . : 0x%X\n", completion->last_completion); weechat_log_printf (" word_found . . . . . . : '%s'\n", completion->word_found); diff --git a/weechat/src/common/completion.h b/weechat/src/common/completion.h index c65d7ce0d..b6e4e735e 100644 --- a/weechat/src/common/completion.h +++ b/weechat/src/common/completion.h @@ -44,6 +44,7 @@ struct t_completion int position; /* position where Tab was pressed */ char *args; /* command line args (including base word) */ int direction; /* +1 = search next word, -1 = previous word */ + int add_space; /* add space after completion? */ /* for command argument completion */ t_weelist *completion_list; /* data list for completion */ diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c index d15ae2e29..424ae94e7 100644 --- a/weechat/src/gui/gui-common.c +++ b/weechat/src/gui/gui-common.c @@ -628,13 +628,16 @@ gui_input_complete (t_gui_window *window) if ((window->buffer->completion.context == COMPLETION_COMMAND) || (window->buffer->completion.context == COMPLETION_COMMAND_ARG)) { - if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer, - window->buffer->input_buffer_pos)] != ' ') - gui_insert_string_input (window, " ", - window->buffer->input_buffer_pos); - if (window->buffer->completion.position >= 0) - window->buffer->completion.position++; - window->buffer->input_buffer_pos++; + if (window->buffer->completion.add_space) + { + if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer, + window->buffer->input_buffer_pos)] != ' ') + gui_insert_string_input (window, " ", + window->buffer->input_buffer_pos); + if (window->buffer->completion.position >= 0) + window->buffer->completion.position++; + window->buffer->input_buffer_pos++; + } } else { |