From ffa0a9ef645fda4a7b3daa8d89ebdfb5202645c8 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 2 Jan 2019 17:44:15 +0100 Subject: [PATCH] tweaks: calculate the length of a completion word in a more direct way --- src/text.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/text.c b/src/text.c index d3a0e1d5..ecc9d635 100644 --- a/src/text.c +++ b/src/text.c @@ -3041,20 +3041,17 @@ void do_verbatim_input(void) } #ifdef ENABLE_WORDCOMPLETION -/* Copy the found completion candidate. */ +/* Return a copy of the found completion candidate. */ char *copy_completion(char *check_line, int start) { char *word; size_t position = start, len_of_word = 0, index = 0; /* Find the length of the word by travelling to its end. */ - while (is_word_mbchar(&check_line[position], FALSE)) { - size_t next = move_mbright(check_line, position); - - len_of_word += next - position; - position = next; - } + while (is_word_mbchar(&check_line[position], FALSE)) + position = move_mbright(check_line, position); + len_of_word = position - start; word = charalloc(len_of_word + 1); /* Simply copy the word. */