Skip to content

Commit

Permalink
FilesCompleter & DirectoriesCompleter: removed boolean constructor pa…
Browse files Browse the repository at this point in the history
…rameter forceSlash, see #476
  • Loading branch information
mattirn committed Jan 16, 2021
1 parent 9a49718 commit a2e21b6
Showing 1 changed file with 2 additions and 41 deletions.
43 changes: 2 additions & 41 deletions builtins/src/main/java/org/jline/builtins/Completers.java
Expand Up @@ -220,44 +220,24 @@ private boolean isTrue(Object result) {
public static class DirectoriesCompleter extends FileNameCompleter {

private final Supplier<Path> currentDir;
private final boolean forceSlash;

public DirectoriesCompleter(File currentDir) {
this(currentDir.toPath(), false);
}

public DirectoriesCompleter(File currentDir, boolean forceSlash) {
this(currentDir.toPath(), forceSlash);
this(currentDir.toPath());
}

public DirectoriesCompleter(Path currentDir) {
this(currentDir, false);
}

public DirectoriesCompleter(Path currentDir, boolean forceSlash) {
this.currentDir = () -> currentDir;
this.forceSlash = forceSlash;
}

public DirectoriesCompleter(Supplier<Path> currentDir) {
this(currentDir, false);
}

public DirectoriesCompleter(Supplier<Path> currentDir, boolean forceSlash) {
this.currentDir = currentDir;
this.forceSlash = forceSlash;
}

@Override
protected Path getUserDir() {
return currentDir.get();
}

@Override
protected String getSeparator(boolean useForwardSlash) {
return forceSlash || useForwardSlash ? "/" : getUserDir().getFileSystem().getSeparator();
}

@Override
protected boolean accept(Path path) {
return Files.isDirectory(path) && super.accept(path);
Expand All @@ -267,43 +247,24 @@ protected boolean accept(Path path) {
public static class FilesCompleter extends FileNameCompleter {

private final Supplier<Path> currentDir;
private final boolean forceSlash;

public FilesCompleter(File currentDir) {
this(currentDir.toPath(), false);
}

public FilesCompleter(File currentDir, boolean forceSlash) {
this(currentDir.toPath(), forceSlash);
this(currentDir.toPath());
}

public FilesCompleter(Path currentDir) {
this(currentDir, false);
}

public FilesCompleter(Path currentDir, boolean forceSlash) {
this.currentDir = () -> currentDir;
this.forceSlash = forceSlash;
}

public FilesCompleter(Supplier<Path> currentDir) {
this(currentDir, false);
}

public FilesCompleter(Supplier<Path> currentDir, boolean forceSlash) {
this.currentDir = currentDir;
this.forceSlash = forceSlash;
}

@Override
protected Path getUserDir() {
return currentDir.get();
}

@Override
protected String getSeparator(boolean useForwardSlash) {
return forceSlash || useForwardSlash ? "/" : getUserDir().getFileSystem().getSeparator();
}
}

/**
Expand Down

0 comments on commit a2e21b6

Please sign in to comment.