Skip to content

Commit

Permalink
Add LineReader option USE_FORWARD_SLASH, fixes #476
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 20, 2019
1 parent 8737ca2 commit 6a0cb70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions builtins/src/main/java/org/jline/builtins/Completers.java
Expand Up @@ -259,8 +259,8 @@ protected Path getUserDir() {
}

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

@Override
Expand Down Expand Up @@ -306,8 +306,8 @@ protected Path getUserDir() {
}

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

Expand Down Expand Up @@ -341,7 +341,7 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi

Path current;
String curBuf;
String sep = getSeparator();
String sep = getSeparator(reader.isSet(LineReader.Option.USE_FORWARD_SLASH));
int lastSep = buffer.lastIndexOf(sep);
try {
if (lastSep >= 0) {
Expand Down Expand Up @@ -396,8 +396,8 @@ protected Path getUserHome() {
return Paths.get(System.getProperty("user.home"));
}

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

protected String getDisplay(Terminal terminal, Path p) {
Expand Down
1 change: 1 addition & 0 deletions reader/src/main/java/org/jline/reader/LineReader.java
Expand Up @@ -406,6 +406,7 @@ enum Option {
DELAY_LINE_WRAP,
AUTO_PARAM_SLASH(true),
AUTO_REMOVE_SLASH(true),
USE_FORWARD_SLASH(false),
/** When hitting the <code>&lt;tab&gt;</code> key at the beginning of the line, insert a tabulation
* instead of completing. This is mainly useful when {@link #BRACKETED_PASTE} is
* disabled, so that copy/paste of indented text does not trigger completion.
Expand Down

0 comments on commit 6a0cb70

Please sign in to comment.