Skip to content

Commit

Permalink
align less config parsing with nanorc theme system
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 27, 2021
1 parent 844ce0b commit 4ce93d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 8 additions & 0 deletions builtins/src/main/java/org/jline/builtins/Less.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ private void parseConfig(Path file) throws IOException {
} else {
syntaxFiles.add(Paths.get(parts.get(1)));
}
} else if(parts.get(0).equals("theme")) {
if (parts.get(1).contains("*") || parts.get(1).contains("?")) {
PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:" + parts.get(1));
Files.find(Paths.get(new File(parts.get(1)).getParent()), Integer.MAX_VALUE, (path, f) -> pathMatcher.matches(path))
.findFirst().ifPresent(path -> syntaxFiles.add(0, path));
} else {
syntaxFiles.add(0, Paths.get(parts.get(1)));
}
} else if (parts.size() == 2
&& (parts.get(0).equals("set") || parts.get(0).equals("unset"))) {
String option = parts.get(1);
Expand Down
7 changes: 2 additions & 5 deletions builtins/src/main/java/org/jline/builtins/Nano.java
Original file line number Diff line number Diff line change
Expand Up @@ -1658,11 +1658,8 @@ private void parseConfig(Path file) throws IOException {
} else if(parts.get(0).equals("theme")) {
if (parts.get(1).contains("*") || parts.get(1).contains("?")) {
PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:" + parts.get(1));
Optional<Path> theme = Files.find(Paths.get(new File(parts.get(1)).getParent()), Integer.MAX_VALUE, (path, f) -> pathMatcher.matches(path))
.findFirst();
if (theme.isPresent()) {
syntaxFiles.add(0, theme.get());
}
Files.find(Paths.get(new File(parts.get(1)).getParent()), Integer.MAX_VALUE, (path, f) -> pathMatcher.matches(path))
.findFirst().ifPresent(path -> syntaxFiles.add(0, path));
} else {
syntaxFiles.add(0, Paths.get(parts.get(1)));
}
Expand Down

0 comments on commit 4ce93d9

Please sign in to comment.