Skip to content

Commit

Permalink
nano command: fixed endOfLine() method. Was failing with wrapped lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jul 28, 2019
1 parent 127212d commit 490b623
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions builtins/src/main/java/org/jline/builtins/Nano.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,12 @@ public void moveTo(int x, int y) {

public void gotoLine(int x, int y) {
line = y < lines.size() ? y : lines.size() - 1;
x = x <= lines.get(line).length() ? x : lines.get(line).length();
x = x <= length(lines.get(line), tabs) ? x : length(lines.get(line), tabs);
firstLineToDisplay = line > 0 ? line - 1 : line;
offsetInLine = 0;
offsetInLineToDisplay = 0;
column = 0;
moveRight(x);
ensureCursorVisible();
curPos();
}

Expand Down Expand Up @@ -793,14 +792,15 @@ public void nextWord() {
public void beginningOfLine() {
column = offsetInLine = 0;
wantedColumn = 0;
ensureCursorVisible();
}

public void endOfLine() {
column = length(lines.get(line), tabs);
int width = size.getColumns() - (printLineNumbers ? 8 : 0);
offsetInLine = (column / width) * (width - 1);
column = column - offsetInLine;
wantedColumn = column;
int x = length(lines.get(line), tabs);
offsetInLine = 0;
offsetInLineToDisplay = 0;
column = 0;
moveRight(x);
}

public void prevPage() {
Expand Down Expand Up @@ -2138,7 +2138,7 @@ protected List<AttributedString> computeFooter() {
}
sb.append('\n');
footer.add(sb.toAttributedString());
} else if (message != null || constantCursor) {
} else if (constantCursor) {
int rwidth = size.getColumns();
String text = "[ " + (message == null ? computeCurPos() : message) + " ]";
int len = text.length();
Expand Down Expand Up @@ -2240,8 +2240,8 @@ protected void bindKeys() {
keys.bind(Operation.UP, ctrl('P'));
keys.bind(Operation.DOWN, ctrl('N'));

keys.bind(Operation.BEGINNING_OF_LINE, ctrl('A'));
keys.bind(Operation.END_OF_LINE, ctrl('E'));
keys.bind(Operation.BEGINNING_OF_LINE, ctrl('A'), key(terminal, Capability.key_home));
keys.bind(Operation.END_OF_LINE, ctrl('E'), key(terminal, Capability.key_end));
keys.bind(Operation.BEGINNING_OF_PARAGRAPH, alt('('), alt('9'));
keys.bind(Operation.END_OF_PARAGRAPH, alt(')'), alt('0'));
keys.bind(Operation.FIRST_LINE, alt('\\'), alt('|'));
Expand Down

1 comment on commit 490b623

@mattirn
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #423

Please sign in to comment.