mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Ticket #2614: Editor word completion should ignore the current word
Currently the completion considers the word the cursor is on as a possible completion, but this is quite annoying if the cursor is inside the word. Such completion effectively inserts the rest of the word one more time, so CamelCase becomes CamelCaseCase. If this is the only match, it completes automatically, which is even worse. The current word shouldn't be used for completion. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
1f24672391
commit
9b86146de2
@ -1028,7 +1028,7 @@ edit_find_word_start (WEdit * edit, long *word_start, gsize * word_len)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/** collect the possible completions */
|
||||
static gsize
|
||||
edit_collect_completions (WEdit * edit, long start, gsize word_len,
|
||||
edit_collect_completions (WEdit * edit, long word_start, gsize word_len,
|
||||
char *match_expr, struct selection *compl, gsize * num)
|
||||
{
|
||||
gsize len = 0;
|
||||
@ -1038,7 +1038,7 @@ edit_collect_completions (WEdit * edit, long start, gsize word_len,
|
||||
GString *temp;
|
||||
mc_search_t *srch;
|
||||
|
||||
long last_byte;
|
||||
long last_byte, start = -1;
|
||||
|
||||
srch = mc_search_new (match_expr, -1);
|
||||
if (srch == NULL)
|
||||
@ -1051,7 +1051,7 @@ edit_collect_completions (WEdit * edit, long start, gsize word_len,
|
||||
}
|
||||
else
|
||||
{
|
||||
last_byte = start;
|
||||
last_byte = word_start;
|
||||
}
|
||||
|
||||
srch->search_type = MC_SEARCH_T_REGEX;
|
||||
@ -1059,7 +1059,6 @@ edit_collect_completions (WEdit * edit, long start, gsize word_len,
|
||||
srch->search_fn = edit_search_cmd_callback;
|
||||
|
||||
/* collect max MAX_WORD_COMPLETIONS completions */
|
||||
start = -1;
|
||||
while (1)
|
||||
{
|
||||
/* get next match */
|
||||
@ -1074,9 +1073,17 @@ edit_collect_completions (WEdit * edit, long start, gsize word_len,
|
||||
skip = edit_get_byte (edit, start + i);
|
||||
if (isspace (skip))
|
||||
continue;
|
||||
|
||||
/* skip current word */
|
||||
if (start + (long) i == word_start)
|
||||
break;
|
||||
|
||||
g_string_append_c (temp, skip);
|
||||
}
|
||||
|
||||
if (temp->len == 0)
|
||||
continue;
|
||||
|
||||
skip = 0;
|
||||
|
||||
for (i = 0; i < (gsize) * num; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user