From 140f2d72cb19584178bc04036bc0c447020ae0f3 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Fri, 22 Jul 2022 13:06:05 -0700 Subject: [PATCH] Fix cutting selection containing a folded segment not unfolding before adding to cutbuffer --- src/cut.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cut.c b/src/cut.c index 055a7abc..85a4a46b 100644 --- a/src/cut.c +++ b/src/cut.c @@ -261,11 +261,20 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_ if (top == bot && top_x == bot_x) return; - UNFOLD_SEGMENT(top); + /* In case bot is the start of a folded segment. + * Folds within [top, bot] are taken care of in the following loop */ + UNFOLD_SEGMENT(bot); if (top != bot) - for (linestruct *line = top->next; line != bot->next; line = line->next) +#ifdef ENABLE_FOLDING + top->folded = FALSE; +#endif + for (linestruct *line = top->next; line != bot->next; line = line->next){ had_anchor |= line->has_anchor; +#ifdef ENABLE_FOLDING + line->folded = FALSE; +#endif + } #endif if (top == bot) { @@ -274,7 +283,6 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_ memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1); last = taken; } else if (top_x == 0 && bot_x == 0) { - UNFOLD_SEGMENT(bot); taken = top; last = make_new_node(NULL); last->data = copy_of(""); @@ -293,7 +301,6 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_ openfile->current = bot; } else { - UNFOLD_SEGMENT(bot); taken = make_new_node(NULL); taken->data = copy_of(top->data + top_x); taken->next = top->next;