Still buggy as hell

This commit is contained in:
sloumdrone 2020-01-02 22:35:04 -08:00
parent 4667adbf8c
commit c84afc7614
1 changed files with 6 additions and 6 deletions

View File

@ -1001,7 +1001,7 @@ void editorMoveCursor(int key) {
switch (key) { switch (key) {
case 'j': case 'j':
case ARROW_DOWN: case ARROW_DOWN:
if (E.cy < E.numRows) { if (E.cy < E.numRows - 1) {
E.cy++; E.cy++;
} }
if (sizeof(row) > 0 && E.cx < 0) E.cx = 0; if (sizeof(row) > 0 && E.cx < 0) E.cx = 0;
@ -1176,7 +1176,6 @@ void editorCommandKp(int c) {
} }
break; break;
case 'o': case 'o':
deleting = 0;
E.cx = E.row[E.cy].size; E.cx = E.row[E.cy].size;
E.mode = InputMode; E.mode = InputMode;
editorMoveCursor(ARROW_RIGHT); editorMoveCursor(ARROW_RIGHT);
@ -1184,9 +1183,10 @@ void editorCommandKp(int c) {
break; break;
case 'O': case 'O':
E.cx = 0; E.cx = 0;
E.mode = InputMode;
editorInsertNewline(); editorInsertNewline();
editorMoveCursor(ARROW_UP); editorMoveCursor(ARROW_UP);
E.mode = InputMode; editorMoveCursor(ARROW_RIGHT);
break; break;
case 'x': case 'x':
while (counter > 0) { while (counter > 0) {
@ -1254,7 +1254,8 @@ void editorCommandKp(int c) {
int start_x = E.cx; int start_x = E.cx;
int start_y = E.cy; int start_y = E.cy;
editorNextWord(); editorNextWord();
editorUpdatePaste(&E.row[E.cy].chars[start_x], E.cx - start_x); int len = start_y == E.cy ? E.cx - start_x : E.row[start_y].size - start_x;
editorUpdatePaste(&E.row[start_y].chars[start_x], len);
while (E.cy != start_y || E.cx != start_x) { while (E.cy != start_y || E.cx != start_x) {
editorDeleteChar(); editorDeleteChar();
} }
@ -1277,12 +1278,11 @@ void editorCommandKp(int c) {
E.mode = InputMode; E.mode = InputMode;
if (open == 'o') editorMoveCursor(ARROW_RIGHT); if (open == 'o') editorMoveCursor(ARROW_RIGHT);
} }
for (int i = 0; i < E.pastelen; i++) { for (int i = 0; i < E.pastelen; i++) {
editorInputKp(E.paste[i]); editorInputKp(E.paste[i]);
} }
if (multiline) { if (multiline) {
editorInputKp(DEL_KEY); editorInputKp(BACKSPACE);
E.cx = startx <= E.row[E.cy].size ? startx : E.row[E.cy].size; E.cx = startx <= E.row[E.cy].size ? startx : E.row[E.cy].size;
} }
E.mode = CommandMode; E.mode = CommandMode;