1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 04:16:38 +02:00

core: fix completion after newline in input (closes #1925)

This commit is contained in:
Sébastien Helleu
2023-05-12 17:53:02 +02:00
parent 6d7f10ef20
commit adbfd27660
2 changed files with 11 additions and 7 deletions
+1
View File
@@ -52,6 +52,7 @@ New features::
Bug fixes::
* core: fix completion after newline in input (issue #1925)
* core: display a specific error when trying to bind a key without area in mouse context
* core: fix display of key with command `/key bindctxt <context> <key>`
* core: fix default value of bar options (issue #846)
+10 -7
View File
@@ -812,7 +812,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
const char *data, int pos)
{
int i, size, command_arg, pos_start, pos_end;
const char *ptr_command, *ptr_data, *prev_char;
const char *ptr_command, *ptr_data, *ptr_space, *ptr_newline, *prev_char;
/* look for context */
gui_completion_free_data (completion);
@@ -845,12 +845,15 @@ gui_completion_find_context (struct t_gui_completion *completion,
ptr_data = data;
while (ptr_data && (ptr_data < data + pos))
{
ptr_data = strchr (ptr_data, ' ');
ptr_space = strchr (ptr_data, ' ');
ptr_newline = strchr (ptr_data, '\n');
ptr_data = (ptr_newline && (!ptr_space || (ptr_newline < ptr_space))) ?
ptr_newline : ptr_space;
if (!ptr_data)
break;
if (ptr_data < data + pos)
{
while ((ptr_data < data + pos) && (ptr_data[0] == ' '))
while ((ptr_data < data + pos) && ((ptr_data[0] == ' ') || (ptr_data[0] == '\n')))
{
ptr_data++;
}
@@ -907,10 +910,10 @@ gui_completion_find_context (struct t_gui_completion *completion,
pos_start = i;
if (data[i] == ' ')
{
if ((i > 0) && (data[i-1] != ' '))
if ((i > 0) && (data[i - 1] != ' ') && (data[i - 1] != '\n'))
{
i--;
while ((i >= 0) && (data[i] != ' '))
while ((i >= 0) && (data[i] != ' ') && (data[i] != '\n'))
{
i--;
}
@@ -919,7 +922,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
}
else
{
while ((i >= 0) && (data[i] != ' '))
while ((i >= 0) && (data[i] != ' ') && (data[i] != '\n'))
{
i--;
}
@@ -934,7 +937,7 @@ gui_completion_find_context (struct t_gui_completion *completion,
{
/* base word stops after first space found (on or after cursor) */
i = pos;
while ((i < size) && (data[i] != ' '))
while ((i < size) && (data[i] != ' ') && (data[i] != '\n'))
{
i++;
}