Fixes single line delete

This commit is contained in:
sloum 2020-03-14 13:55:50 -07:00
parent 01e0f008d4
commit 91476f21d5
1 changed files with 24 additions and 11 deletions

View File

@ -1348,6 +1348,18 @@ void editorCommandKp(int c) {
} else if (!deleting) {
deleting++;
return;
} else {
if (counter <= 1) {
int sz = E.row[E.cy].size + 1;
char *buf = malloc(sz);
strcpy(buf, E.row[E.cy].chars);
buf[sz - 1] = '\r';
editorUpdatePaste(buf, sz);
free(buf);
editorDelRow(E.cy);
if (E.cy == E.numRows) E.cy--;
if (E.cy < 0) E.cy = 0;
if (E.cx >= E.row[E.cy].size) E.cx = 0;
} else {
int start_x = E.cx;
int start_y = E.cy;
@ -1364,6 +1376,7 @@ void editorCommandKp(int c) {
}
E.cx = start_x;
if (E.cx >= E.row[E.cy].size) E.cx = E.row[E.cy].size - 1;
}
break;
}
case '$':