Fixes numerical looping delete for w
This commit is contained in:
parent
feb92b21eb
commit
96d5cf4dc4
39
hermes.c
39
hermes.c
|
@ -947,7 +947,7 @@ void editorCopyRange(int sx, int sy, int ex, int ey) {
|
||||||
|
|
||||||
int totlen = 0;
|
int totlen = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
if (ey - sy == 0) {
|
if (ey == sy) {
|
||||||
totlen = ex - sx + 1;
|
totlen = ex - sx + 1;
|
||||||
buf = malloc(totlen);
|
buf = malloc(totlen);
|
||||||
memcpy(buf, &E.row[sy].chars[sx], totlen);
|
memcpy(buf, &E.row[sy].chars[sx], totlen);
|
||||||
|
@ -1314,25 +1314,28 @@ void editorCommandKp(int c) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
while (counter > 0) {
|
{
|
||||||
if (deleting) {
|
int start_x = E.cx;
|
||||||
int start_x = E.cx;
|
int start_y = E.cy;
|
||||||
int start_y = E.cy;
|
while (counter > 0) {
|
||||||
editorNextWord();
|
|
||||||
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);
|
|
||||||
if (E.cy != start_y) {
|
|
||||||
E.cy--;
|
|
||||||
E.cx = E.row[E.cy].size;
|
|
||||||
}
|
|
||||||
while (E.cx != start_x) {
|
|
||||||
editorDeleteChar();
|
|
||||||
}
|
|
||||||
if (E.cx > E.row[E.cy].size - 1) E.cx--;
|
|
||||||
} else {
|
|
||||||
editorNextWord();
|
editorNextWord();
|
||||||
|
counter--;
|
||||||
}
|
}
|
||||||
counter--;
|
if (!deleting) break;
|
||||||
|
int end_x, end_y;
|
||||||
|
if (E.cx == 0) {
|
||||||
|
if (E.cy == 0) break;
|
||||||
|
end_y = E.cy - 1;
|
||||||
|
end_x = E.row[E.cy].size - 1;
|
||||||
|
} else {
|
||||||
|
end_x = E.cx - 1;
|
||||||
|
end_y = E.cy;
|
||||||
|
}
|
||||||
|
editorCopyRange(start_x, start_y, end_x, end_y);
|
||||||
|
while (E.cx != start_x || E.cy != start_y) {
|
||||||
|
editorDeleteChar();
|
||||||
|
}
|
||||||
|
if (E.cx > E.row[E.cy].size - 1) E.cx = E.row[E.cy].size - 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
|
|
Loading…
Reference in New Issue