tweaks: instead of swapping the end points later, assign them correctly
(This also makes it clear that the naming of 'head' and 'tail' is the wrong way around for CUT too.)master
parent
bd88b8b5a6
commit
132ed5c8f0
27
src/text.c
27
src/text.c
|
@ -1179,9 +1179,17 @@ void add_undo(undo_type action, const char *message)
|
||||||
case ZAP:
|
case ZAP:
|
||||||
case CUT:
|
case CUT:
|
||||||
if (openfile->mark) {
|
if (openfile->mark) {
|
||||||
|
u->xflags |= MARK_WAS_SET;
|
||||||
|
if (openfile->mark->lineno < openfile->current->lineno ||
|
||||||
|
(openfile->mark == openfile->current &&
|
||||||
|
openfile->mark_x < openfile->current_x)) {
|
||||||
u->tail_lineno = openfile->mark->lineno;
|
u->tail_lineno = openfile->mark->lineno;
|
||||||
u->tail_x = openfile->mark_x;
|
u->tail_x = openfile->mark_x;
|
||||||
u->xflags |= MARK_WAS_SET;
|
u->xflags |= WAS_MARKED_FORWARD;
|
||||||
|
} else {
|
||||||
|
u->head_lineno = openfile->mark->lineno;
|
||||||
|
u->head_x = openfile->mark_x;
|
||||||
|
}
|
||||||
if (openfile->current == openfile->filebot ||
|
if (openfile->current == openfile->filebot ||
|
||||||
openfile->mark == openfile->filebot)
|
openfile->mark == openfile->filebot)
|
||||||
u->xflags |= WAS_FINAL_LINE;
|
u->xflags |= WAS_FINAL_LINE;
|
||||||
|
@ -1323,22 +1331,7 @@ void update_undo(undo_type action)
|
||||||
free_lines(u->cutbuffer);
|
free_lines(u->cutbuffer);
|
||||||
u->cutbuffer = copy_buffer(cutbuffer);
|
u->cutbuffer = copy_buffer(cutbuffer);
|
||||||
}
|
}
|
||||||
if (u->xflags & MARK_WAS_SET) {
|
if (!(u->xflags & MARK_WAS_SET)) {
|
||||||
/* If the region was marked backwards, swap the end points. */
|
|
||||||
if (u->head_lineno < u->tail_lineno ||
|
|
||||||
(u->head_lineno == u->tail_lineno &&
|
|
||||||
u->head_x < u->tail_x)) {
|
|
||||||
ssize_t number = u->head_lineno;
|
|
||||||
size_t position = u->head_x;
|
|
||||||
|
|
||||||
u->head_lineno = u->tail_lineno;
|
|
||||||
u->head_x = u->tail_x;
|
|
||||||
|
|
||||||
u->tail_lineno = number;
|
|
||||||
u->tail_x = position;
|
|
||||||
} else
|
|
||||||
u->xflags |= WAS_MARKED_FORWARD;
|
|
||||||
} else {
|
|
||||||
linestruct *bottomline = u->cutbuffer;
|
linestruct *bottomline = u->cutbuffer;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue