commit 732cf8878656a88a20292bd3ba1d1e9867bffdf3
parent 9fb0beca1d669c33b880f17703f940093232bc12
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 28 Mar 2020 17:06:47 +0100
text: retain a bookmark when two lines are joined or something is cut
Also, do not copy the bookmark into the cutbuffer, so it will not get
pasted elsewhere.
Diffstat:
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/cut.c b/src/cut.c
@@ -87,6 +87,8 @@ void do_deletion(undo_type action)
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x;
}
+
+ openfile->current->bookmarked |= joining->bookmarked;
#endif
unlink_node(joining);
renumber_from(openfile->current);
@@ -246,9 +248,14 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
bool same_line = (openfile->mark == top);
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
(same_line && openfile->mark_x > top_x)));
+ bool was_bookmarked = top->bookmarked;
if (top == bot && top_x == bot_x)
return;
+
+ if (top != bot)
+ for (linestruct *line = top->next; line != bot->next; line = line->next)
+ was_bookmarked |= line->bookmarked;
#endif
if (top == bot) {
@@ -318,6 +325,8 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
openfile->current_x = top_x;
#ifndef NANO_TINY
+ openfile->current->bookmarked = was_bookmarked;
+
if (post_marked || same_line)
openfile->mark = openfile->current;
if (post_marked)
diff --git a/src/nano.c b/src/nano.c
@@ -151,7 +151,7 @@ linestruct *copy_node(const linestruct *src)
#endif
dst->lineno = src->lineno;
#ifndef NANO_TINY
- dst->bookmarked = src->bookmarked;
+ dst->bookmarked = FALSE;
#endif
return dst;
diff --git a/src/text.c b/src/text.c
@@ -535,6 +535,7 @@ void do_undo(void)
line->data = charealloc(line->data, strlen(line->data) +
strlen(&u->strdata[regain_from_x]) + 1);
strcat(line->data, &u->strdata[regain_from_x]);
+ line->bookmarked |= line->next->bookmarked;
unlink_node(line->next);
renumber_from(line);
goto_line_posx(u->head_lineno, original_x);