Ticket #2456 (Incorrect restore selection after UNDO)

fixed incorrect restore selection after UNDO

    test case:
        1. mcedit new_empty_file
        2. type in 0123456789
        3. F3 5*left F3 - digit '4' is not marked at this point
        4. backspace, ctrl-u - digit '4' is marked now
        5. left, 2*del, 2*ctrl-u - digits '4' and '5' are not marked

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
Ilia Maslakov 2011-01-29 23:40:18 +00:00
parent 9b5de3c96b
commit afb498de3a
2 changed files with 19 additions and 3 deletions

View File

@ -110,8 +110,9 @@
#define DELCHAR_BR 610
#define BACKSPACE_BR 611
#define MARK_1 1000
#define MARK_2 700000000
#define KEY_PRESS 1400000000
#define MARK_2 500000000
#define MARK_CURS 1000000000
#define KEY_PRESS 1500000000
/* Tabs spaces: (sofar only HALF_TAB_SIZE is used: */
#define TAB_SIZE option_tab_spacing

View File

@ -705,6 +705,9 @@ edit_backspace (WEdit * edit, const int byte_delete)
cw = 1;
if (edit->mark2 != edit->mark1)
edit_push_markers (edit);
if (edit->utf8 && byte_delete == 0)
{
edit_get_prev_utf (edit, edit->curs1, &cw);
@ -1296,11 +1299,15 @@ edit_do_undo (WEdit * edit)
edit->mark1 = ac - MARK_1;
edit->column1 = edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1);
}
else if (ac >= MARK_2 - 2 && ac < KEY_PRESS)
if (ac >= MARK_2 - 2 && ac < MARK_CURS - 2)
{
edit->mark2 = ac - MARK_2;
edit->column2 = edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2);
}
else if (ac >= MARK_CURS - 2 && ac < KEY_PRESS)
{
edit->end_mark_curs = ac - MARK_CURS;
}
if (count++)
edit->force |= REDRAW_PAGE; /* more than one pop usually means something big */
}
@ -2704,6 +2711,10 @@ edit_delete (WEdit * edit, const int byte_delete)
if (cw < 1)
cw = 1;
}
if (edit->mark2 != edit->mark1)
edit_push_markers (edit);
for (i = 1; i <= cw; i++)
{
if (edit->mark1 > edit->curs1)
@ -3170,6 +3181,7 @@ edit_push_markers (WEdit * edit)
{
edit_push_undo_action (edit, MARK_1 + edit->mark1);
edit_push_undo_action (edit, MARK_2 + edit->mark2);
edit_push_undo_action (edit, MARK_CURS + edit->end_mark_curs);
}
/* --------------------------------------------------------------------------------------------- */
@ -3297,7 +3309,10 @@ edit_push_key_press (WEdit * edit)
{
edit_push_undo_action (edit, KEY_PRESS + edit->start_display);
if (edit->mark2 == -1)
{
edit_push_undo_action (edit, MARK_1 + edit->mark1);
edit_push_undo_action (edit, MARK_CURS + edit->end_mark_curs);
}
}
/* --------------------------------------------------------------------------------------------- */