summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-07-06 10:06:47 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-07-06 10:06:47 +0200
commit00ca4f0d36d482b2814f3829f572b9872ab63b34 (patch)
treef052fb63f17ccf591a7dd0e08c1cdf647bf13a77 /src/gui
parent05deb6356a340d62687db431e938996cd15834db (diff)
downloadweechat-00ca4f0d36d482b2814f3829f572b9872ab63b34.zip
Complete command and arguments even if command line starts with double '/'
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-completion.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 8d11da52e..80cd95474 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -1536,7 +1536,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
/* look for context */
gui_completion_free_data (completion);
gui_completion_buffer_init (completion, completion->buffer);
- command = ((data[0] == '/') && (data[1] != '/')) ? 1 : 0;
+ command = (data[0] == '/') ? 1 : 0;
command_arg = 0;
i = 0;
while (i < pos)
@@ -1545,7 +1545,10 @@ gui_completion_find_context (struct t_gui_completion *completion,
{
command_arg++;
i++;
- while ((i < pos) && (data[i] == ' ')) i++;
+ while ((i < pos) && (data[i] == ' '))
+ {
+ i++;
+ }
if (!completion->args)
completion->args = strdup (data + i);
}
@@ -1582,23 +1585,33 @@ gui_completion_find_context (struct t_gui_completion *completion,
{
i--;
while ((i >= 0) && (data[i] != ' '))
+ {
i--;
+ }
pos_start = i + 1;
}
}
else
{
while ((i >= 0) && (data[i] != ' '))
+ {
i--;
+ }
pos_start = i + 1;
}
i = pos;
while ((i < size) && (data[i] != ' '))
+ {
i++;
+ }
pos_end = i - 1;
if (completion->context == GUI_COMPLETION_COMMAND)
+ {
pos_start++;
+ if (data[pos_start] == '/')
+ pos_start++;
+ }
completion->base_word_pos = pos_start;
@@ -1607,7 +1620,9 @@ gui_completion_find_context (struct t_gui_completion *completion,
completion->position_replace = pos_start;
completion->base_word = malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
+ {
completion->base_word[i - pos_start] = data[i];
+ }
completion->base_word[pos_end - pos_start + 1] = '\0';
}
}
@@ -1620,19 +1635,27 @@ gui_completion_find_context (struct t_gui_completion *completion,
{
pos_start = 0;
while ((pos_start < size) && (data[pos_start] != '/'))
+ {
pos_start++;
+ }
if (data[pos_start] == '/')
{
pos_start++;
+ if (data[pos_start] == '/')
+ pos_start++;
pos_end = pos_start;
while ((pos_end < size) && (data[pos_end] != ' '))
+ {
pos_end++;
+ }
if (data[pos_end] == ' ')
pos_end--;
completion->base_command = malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
+ {
completion->base_command[i - pos_start] = data[i];
+ }
completion->base_command[pos_end - pos_start + 1] = '\0';
gui_completion_build_list (completion);
}