set editor position

This commit is contained in:
2025-11-24 21:35:40 -08:00
parent f8f01f7dd6
commit af3c0eddc4

15
main.c
View File

@@ -761,10 +761,9 @@ kill_region(void)
/* kill the current killring */ /* kill the current killring */
killring_flush(); killring_flush();
if (!cursor_after_mark()) { if (!cursor_after_mark()) {
swap_int(&curx, &markx); swap_int(&curx, &markx);
swap_int(&curx, &marky); swap_int(&cury, &marky);
} }
editor.curx = markx; editor.curx = markx;
@@ -796,11 +795,23 @@ delete_region(void)
{ {
int count = count_chars_from_cursor_to_mark(); int count = count_chars_from_cursor_to_mark();
int killed = 0; int killed = 0;
int curx = editor.curx;
int cury = editor.cury;
int markx = editor.mark_curx;
int marky = editor.mark_cury;
if (!editor.mark_set) { if (!editor.mark_set) {
return; return;
} }
if (!cursor_after_mark()) {
swap_int(&curx, &markx);
swap_int(&cury, &marky);
}
editor.curx = markx;
editor.cury = marky;
while (killed < count) { while (killed < count) {
move_cursor(ARROW_RIGHT); move_cursor(ARROW_RIGHT);