Skip to content

Commit

Permalink
Remove all references to File.separator, #173
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Apr 8, 2018
1 parent a5cc30e commit d7b1348
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions builtins/src/main/java/org/jline/builtins/Completers.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,12 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi

Path current;
String curBuf;
int lastSep = buffer.lastIndexOf(File.separator);
String sep = getUserDir().getFileSystem().getSeparator();
int lastSep = buffer.lastIndexOf(sep);
if (lastSep >= 0) {
curBuf = buffer.substring(0, lastSep + 1);
if (curBuf.startsWith("~")) {
if (curBuf.startsWith("~/")) {
if (curBuf.startsWith("~" + sep)) {
current = getUserHome().resolve(curBuf.substring(2));
} else {
current = getUserHome().getParent().resolve(curBuf.substring(1));
Expand All @@ -306,10 +307,10 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi
String value = curBuf + p.getFileName().toString();
if (Files.isDirectory(p)) {
candidates.add(new Candidate(
value + (reader.isSet(LineReader.Option.AUTO_PARAM_SLASH) ? File.separator : ""),
value + (reader.isSet(LineReader.Option.AUTO_PARAM_SLASH) ? sep : ""),
getDisplay(reader.getTerminal(), p),
null, null,
reader.isSet(LineReader.Option.AUTO_REMOVE_SLASH) ? File.separator : null,
reader.isSet(LineReader.Option.AUTO_REMOVE_SLASH) ? sep : null,
null,
false));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi

Path current;
String curBuf;
int lastSep = buffer.lastIndexOf(File.separator);
String sep = getUserDir().getFileSystem().getSeparator();
int lastSep = buffer.lastIndexOf(sep);
if (lastSep >= 0) {
curBuf = buffer.substring(0, lastSep + 1);
if (curBuf.startsWith("~")) {
if (curBuf.startsWith("~/")) {
if (curBuf.startsWith("~" + sep)) {
current = getUserHome().resolve(curBuf.substring(2));
} else {
current = getUserHome().getParent().resolve(curBuf.substring(1));
Expand All @@ -79,10 +80,10 @@ public void complete(LineReader reader, ParsedLine commandLine, final List<Candi
String value = curBuf + p.getFileName().toString();
if (Files.isDirectory(p)) {
candidates.add(new Candidate(
value + (reader.isSet(Option.AUTO_PARAM_SLASH) ? "/" : ""),
value + (reader.isSet(Option.AUTO_PARAM_SLASH) ? sep : ""),
getDisplay(reader.getTerminal(), p),
null, null,
reader.isSet(Option.AUTO_REMOVE_SLASH) ? "/" : null,
reader.isSet(Option.AUTO_REMOVE_SLASH) ? sep : null,
null,
false));
} else {
Expand Down

0 comments on commit d7b1348

Please sign in to comment.