copy: properly set preferred x position when region was marked backwards
This fixes https://savannah.gnu.org/bugs/?49964.master
parent
e1538e6dc3
commit
d3429a7a57
13
src/cut.c
13
src/cut.c
|
@ -60,13 +60,13 @@ void cut_line(void)
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Move all currently marked text into the cutbuffer, and set the
|
/* Move all currently marked text into the cutbuffer, and set the
|
||||||
* current place we want to where the text used to start. */
|
* current place we want to where the text used to start. */
|
||||||
void cut_marked(void)
|
void cut_marked(bool *right_side_up)
|
||||||
{
|
{
|
||||||
filestruct *top, *bot;
|
filestruct *top, *bot;
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
|
|
||||||
mark_order((const filestruct **)&top, &top_x,
|
mark_order((const filestruct **)&top, &top_x,
|
||||||
(const filestruct **)&bot, &bot_x, NULL);
|
(const filestruct **)&bot, &bot_x, right_side_up);
|
||||||
|
|
||||||
move_to_filestruct(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
|
move_to_filestruct(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
|
||||||
openfile->placewewant = xplustabs();
|
openfile->placewewant = xplustabs();
|
||||||
|
@ -124,6 +124,8 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||||
/* The length of the string at the current end of the cutbuffer,
|
/* The length of the string at the current end of the cutbuffer,
|
||||||
* before we add text to it. */
|
* before we add text to it. */
|
||||||
bool old_no_newlines = ISSET(NO_NEWLINES);
|
bool old_no_newlines = ISSET(NO_NEWLINES);
|
||||||
|
bool right_side_up = TRUE;
|
||||||
|
/* There *is* no region, *or* it is marked forward. */
|
||||||
#endif
|
#endif
|
||||||
size_t was_totsize = openfile->totsize;
|
size_t was_totsize = openfile->totsize;
|
||||||
|
|
||||||
|
@ -156,7 +158,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||||
cut_to_eof();
|
cut_to_eof();
|
||||||
} else if (openfile->mark_set) {
|
} else if (openfile->mark_set) {
|
||||||
/* Move the marked text to the cutbuffer, and turn the mark off. */
|
/* Move the marked text to the cutbuffer, and turn the mark off. */
|
||||||
cut_marked();
|
cut_marked(&right_side_up);
|
||||||
openfile->mark_set = FALSE;
|
openfile->mark_set = FALSE;
|
||||||
} else if (ISSET(CUT_TO_END))
|
} else if (ISSET(CUT_TO_END))
|
||||||
/* Move all text up to the end of the line into the cutbuffer. */
|
/* Move all text up to the end of the line into the cutbuffer. */
|
||||||
|
@ -179,7 +181,10 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
|
||||||
} else
|
} else
|
||||||
copy_from_filestruct(cutbuffer);
|
copy_from_filestruct(cutbuffer);
|
||||||
|
|
||||||
openfile->placewewant = xplustabs();
|
/* If the copied region was marked forward, put the new desired
|
||||||
|
* x position at its end; otherwise, leave it at its beginning. */
|
||||||
|
if (right_side_up)
|
||||||
|
openfile->placewewant = xplustabs();
|
||||||
}
|
}
|
||||||
/* Restore the magicline behavior now that we're done fiddling. */
|
/* Restore the magicline behavior now that we're done fiddling. */
|
||||||
if (!old_no_newlines)
|
if (!old_no_newlines)
|
||||||
|
|
|
@ -276,7 +276,7 @@ void cutbuffer_reset(void);
|
||||||
bool keeping_cutbuffer(void);
|
bool keeping_cutbuffer(void);
|
||||||
void cut_line(void);
|
void cut_line(void);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
void cut_marked(void);
|
void cut_marked(bool *right_side_up);
|
||||||
void cut_to_eol(void);
|
void cut_to_eol(void);
|
||||||
void cut_to_eof(void);
|
void cut_to_eof(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -798,7 +798,7 @@ void do_undo(void)
|
||||||
openfile->mark_begin_x = u->mark_begin_x;
|
openfile->mark_begin_x = u->mark_begin_x;
|
||||||
openfile->mark_set = TRUE;
|
openfile->mark_set = TRUE;
|
||||||
goto_line_posx(u->lineno, u->begin);
|
goto_line_posx(u->lineno, u->begin);
|
||||||
cut_marked();
|
cut_marked(NULL);
|
||||||
free_filestruct(u->cutbuffer);
|
free_filestruct(u->cutbuffer);
|
||||||
u->cutbuffer = cutbuffer;
|
u->cutbuffer = cutbuffer;
|
||||||
u->cutbottom = cutbottom;
|
u->cutbottom = cutbottom;
|
||||||
|
|
Loading…
Reference in New Issue