fix C-e bug
This commit is contained in:
18
main.c
18
main.c
@@ -2473,7 +2473,7 @@ move_cursor_once(int16_t c, int interactive)
|
|||||||
break;
|
break;
|
||||||
case END_KEY:
|
case END_KEY:
|
||||||
case CTRL_KEY('e'):
|
case CTRL_KEY('e'):
|
||||||
if (editor.nrows == 0) {
|
if (editor.cury >= editor.nrows) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
editor.curx = editor.row[editor.cury].size;
|
editor.curx = editor.row[editor.cury].size;
|
||||||
@@ -2481,13 +2481,6 @@ move_cursor_once(int16_t c, int interactive)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
row = (editor.cury >= editor.nrows) ? NULL : &editor.row[editor.cury];
|
|
||||||
reps = row ? row->size : 0;
|
|
||||||
if (editor.curx > reps) {
|
|
||||||
editor.curx = reps;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2508,10 +2501,13 @@ newline(void)
|
|||||||
struct erow *row = NULL;
|
struct erow *row = NULL;
|
||||||
|
|
||||||
if (editor.cury >= editor.nrows) {
|
if (editor.cury >= editor.nrows) {
|
||||||
/* At or past end of file, insert empty line */
|
|
||||||
erow_insert(editor.cury, "", 0);
|
erow_insert(editor.cury, "", 0);
|
||||||
|
editor.cury++;
|
||||||
|
editor.curx = 0;
|
||||||
} else if (editor.curx == 0) {
|
} else if (editor.curx == 0) {
|
||||||
erow_insert(editor.cury, "", 0);
|
erow_insert(editor.cury, "", 0);
|
||||||
|
editor.cury++;
|
||||||
|
editor.curx = 0;
|
||||||
} else {
|
} else {
|
||||||
row = &editor.row[editor.cury];
|
row = &editor.row[editor.cury];
|
||||||
erow_insert(editor.cury + 1,
|
erow_insert(editor.cury + 1,
|
||||||
@@ -2521,10 +2517,10 @@ newline(void)
|
|||||||
row->size = editor.curx;
|
row->size = editor.curx;
|
||||||
row->line[row->size] = '\0';
|
row->line[row->size] = '\0';
|
||||||
erow_update(row);
|
erow_update(row);
|
||||||
|
editor.cury++;
|
||||||
|
editor.curx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.cury++;
|
|
||||||
editor.curx = 0;
|
|
||||||
/* BREAK THE KILL CHAIN \m/ */
|
/* BREAK THE KILL CHAIN \m/ */
|
||||||
editor.kill = 0;
|
editor.kill = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user