Skip to content

Commit

Permalink
lsStyle resolver defined as static field, fixes #764
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jan 24, 2022
1 parent bfcc415 commit ac26d10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions builtins/src/main/java/org/jline/builtins/Completers.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ protected boolean accept(Path path) {
*/
public static class FileNameCompleter implements org.jline.reader.Completer
{
protected static StyleResolver resolver = Styles.lsStyle();

public void complete(LineReader reader, ParsedLine commandLine, final List<Candidate> candidates) {
assert commandLine != null;
Expand Down Expand Up @@ -358,6 +357,7 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi
curBuf = "";
current = getUserDir();
}
StyleResolver resolver = Styles.lsStyle();
try (DirectoryStream<Path> directory = Files.newDirectoryStream(current, this::accept)) {
directory.forEach(p -> {
String value = curBuf + p.getFileName().toString();
Expand Down Expand Up @@ -696,7 +696,7 @@ protected boolean completeValue(LineReader reader, final ParsedLine commandLine,
if (valueCompleter instanceof FileNameCompleter) {
FileNameCompleter cc = (FileNameCompleter)valueCompleter;
String sep = cc.getSeparator(reader.isSet(LineReader.Option.USE_FORWARD_SLASH));
val = cc.getDisplay(reader.getTerminal(), Paths.get(c.value()), FileNameCompleter.resolver, sep);
val = cc.getDisplay(reader.getTerminal(), Paths.get(c.value()), Styles.lsStyle(), sep);
}
candidates.add(new Candidate(curBuf + v, val, null, null, null, null, c.complete()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021, the original author or authors.
* Copyright (c) 2002-2022, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -36,7 +36,7 @@
* @author <a href="mailto:matti.rintanikkola@gmail.com">Matti Rinta-Nikkola</a>
*/
public class SystemHighlighter extends DefaultHighlighter {
private final static StyleResolver resolver = Styles.lsStyle();
private StyleResolver resolver = Styles.lsStyle();
private final static String REGEX_COMMENT_LINE = "\\s*#.*";
private final static String READER_COLORS = "READER_COLORS";
protected final SyntaxHighlighter commandHighlighter;
Expand Down Expand Up @@ -99,6 +99,7 @@ public void refresh(LineReader lineReader) {
for (Supplier<Boolean> refresh : externalHighlightersRefresh) {
refresh.get();
}
resolver = Styles.lsStyle();
} catch (IOException e) {
Log.warn(e.getMessage());
}
Expand Down

0 comments on commit ac26d10

Please sign in to comment.