Skip to content

Commit

Permalink
nano editor fails to highlight block comments, fixes #753
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 27, 2021
1 parent f759ea6 commit 844ce0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Less.java
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,12 @@ synchronized boolean display(boolean oneScreen, Integer curPos) throws IOExcepti
Pattern dpCompiled = getPattern(true);
boolean fitOnOneScreen = false;
boolean eof = false;
syntaxHighlighter.reset();
if (highlight) {
syntaxHighlighter.reset();
for (int i = Math.max(0, inputLine - height); i < inputLine; i++) {
syntaxHighlighter.highlight(getLine(i));
}
}
for (int terminalLine = 0; terminalLine < height - 1; terminalLine++) {
if (curLine == null) {
Pair<Integer, AttributedString> nextLine = nextLine2display(inputLine, dpCompiled);
Expand Down
7 changes: 6 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Nano.java
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,12 @@ List<AttributedString> getDisplayedLines(int nbLines) {
int curLine = firstLineToDisplay;
int curOffset = offsetInLineToDisplay;
int prevLine = -1;
syntaxHighlighter.reset();
if (highlight) {
syntaxHighlighter.reset();
for (int i = Math.max(0, curLine - nbLines); i < curLine; i++) {
syntaxHighlighter.highlight(getLine(i));
}
}
for (int terminalLine = 0; terminalLine < nbLines; terminalLine++) {
AttributedStringBuilder line = new AttributedStringBuilder().tabs(tabs);
if (printLineNumbers && curLine < lines.size()) {
Expand Down

0 comments on commit 844ce0b

Please sign in to comment.