Skip to content

Commit

Permalink
KILL_WHOLE_LINE doesn't work for last line in buffer, fixes #339
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jan 29, 2019
1 parent b807f97 commit a8ce4e8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5003,7 +5003,9 @@ protected boolean killWholeLine() {
while (end < buf.length() && buf.atChar(end) != '\n') {
end++;
}
end++;
if (end < buf.length()) {
end++;
}
}
}
String killed = buf.substring(start, end);
Expand Down
8 changes: 8 additions & 0 deletions reader/src/test/java/org/jline/reader/impl/KillRingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.jline.reader.LineReader.BACKWARD_KILL_WORD;
import static org.jline.reader.LineReader.BACKWARD_WORD;
import static org.jline.reader.LineReader.KILL_WHOLE_LINE;
import static org.jline.reader.LineReader.KILL_WORD;
import static org.jline.reader.LineReader.YANK;
import static org.jline.reader.LineReader.YANK_POP;
Expand Down Expand Up @@ -174,4 +175,11 @@ public void testBufferMixedKillsAndYank() throws Exception {
assertBuffer("", b = b.op(BACKWARD_KILL_WORD));
assertBuffer("This is a test", b = b.op(YANK));
}

@Test
public void testKillWholeLine() throws Exception {
TestBuffer b = new TestBuffer("b");
assertBuffer("", b = b.op(KILL_WHOLE_LINE));
assertBuffer("b", b = b.op(YANK));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.jline.reader.LineReader.DOWN_HISTORY;
import static org.jline.reader.LineReader.END_OF_LINE;
import static org.jline.reader.LineReader.FORWARD_WORD;
import static org.jline.reader.LineReader.KILL_WHOLE_LINE;
import static org.jline.reader.LineReader.KILL_WORD;
import static org.jline.reader.LineReader.UP_HISTORY;
import static org.jline.reader.LineReader.YANK;
Expand Down Expand Up @@ -164,6 +165,7 @@ private String getKeyForAction(final String key) {
case BEGINNING_OF_LINE: return "\033[H";
case END_OF_LINE: return "\u0005";
case KILL_WORD: return "\u001Bd";
case KILL_WHOLE_LINE: return "\u0015";
case BACKWARD_KILL_WORD: return "\u0017";
case ACCEPT_LINE: return "\n";
case UP_HISTORY: return "\033[A";
Expand Down

0 comments on commit a8ce4e8

Please sign in to comment.