diff --git a/src/text.c b/src/text.c index 516f4ce..9a3e137 100644 --- a/src/text.c +++ b/src/text.c @@ -3727,6 +3727,7 @@ void complete_a_word(void) int start_of_shard, shard_length = 0; int i = 0, j = 0; completion_word *some_word; + bool was_set_wrapping = !ISSET(NO_WRAP); /* If this is a fresh completion attempt... */ if (pletion_line == NULL) { @@ -3778,6 +3779,8 @@ void complete_a_word(void) return; } + SET(NO_WRAP); + shard = (char *)nmalloc((openfile->current_x - start_of_shard + 1) * sizeof(char)); /* Copy the fragment that has to be searched for. */ @@ -3845,8 +3848,7 @@ void complete_a_word(void) /* Mark the position for a possible next search attempt. */ pletion_x = ++i; - free(shard); - return; + goto completed; } pletion_line = pletion_line->next; @@ -3860,5 +3862,9 @@ void complete_a_word(void) } else statusline(ALERT, _("No matches")); + completed: + if (was_set_wrapping) + UNSET(NO_WRAP); + free(shard); }