Skip to content

Commit

Permalink
Bug fix: nano breaks if status enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jun 7, 2019
1 parent f1dce10 commit 31d7d9d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions builtins/src/main/java/org/jline/builtins/Less.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ public void run(List<Source> sources) throws IOException, InterruptedException {

sourceIdx = 0;
openSource();
Status status = Status.getStatus(terminal, false);

try {
Status.getStatus(terminal).suspend();
if (status != null) {
status.suspend();
}
size.copy(terminal.getSize());

if (quitIfOneScreen && sources.size() == 1) {
Expand Down Expand Up @@ -408,7 +411,9 @@ else if (buffer.length() > 0 && (buffer.charAt(0) == '/' || buffer.charAt(0) ==
}
} finally {
reader.close();
Status.getStatus(terminal).restore();
if (status != null) {
status.restore();
}
}
}

Expand Down
10 changes: 9 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Nano.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import org.jline.utils.Display;
import org.jline.utils.Status;
import org.jline.utils.InfoCmp.Capability;
import org.mozilla.universalchardet.UniversalDetector;

Expand Down Expand Up @@ -994,7 +995,11 @@ public void run() throws IOException {
this.shortcuts = standardShortcuts();

SignalHandler prevHandler = null;
Status status = Status.getStatus(terminal, false);
try {
if (status != null) {
status.suspend();
}
buffer.open();
if (buffer.file != null) {
setMessage("Read " + buffer.lines.size() + " lines");
Expand Down Expand Up @@ -1139,7 +1144,10 @@ public void run() throws IOException {
terminal.flush();
terminal.setAttributes(attributes);
terminal.handle(Signal.WINCH, prevHandler);
}
if (status != null) {
status.restore();
}
}
}

boolean write() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public static AttributedString fromAnsi(String ansi, List<Integer> tabs) {
.toAttributedString();
}


public static String stripAnsi(String ansi) {
if (ansi == null) {
return null;
Expand Down

0 comments on commit 31d7d9d

Please sign in to comment.