diff --git a/hermes.c b/hermes.c index 41b269f..1d3cb49 100644 --- a/hermes.c +++ b/hermes.c @@ -1256,9 +1256,14 @@ void editorCommandKp(int c) { 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); - while (E.cy != start_y || E.cx != start_x) { + 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(); }