Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed command tab complete not scanning softlink folders #7186

Open
wants to merge 15 commits into
base: dev/feature
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/main/java/ch/njol/skript/SkriptCommandTabCompleter.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public List<String> onTabComplete(CommandSender sender, Command command, String

// Live update, this will get all old and new (even not loaded) scripts
// TODO Find a better way for caching, it isn't exactly ideal to be calling this method constantly
try (Stream<Path> files = Files.walk(scripts.toPath())) {
try (Stream<Path> files = Files.walk(scripts.toPath(), java.nio.file.FileVisitOption.FOLLOW_LINKS)) {
killertuling marked this conversation as resolved.
Show resolved Hide resolved
files.map(Path::toFile)
.forEach(file -> {
if (!(enable ? ScriptLoader.getDisabledScriptsFilter() : ScriptLoader.getLoadedScriptsFilter()).accept(file))
Expand All @@ -69,6 +69,17 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
if (file.isHidden())
return;

// When following a soft link on linux, additional processing may be required to detect whether the content pointed to by the symbolic link exists
if (Files.isSymbolicLink(file.toPath())) {
try {
Path resolvedPath = file.toPath().toRealPath();
if (!Files.exists(resolvedPath))
return;
} catch (Exception e) {
return;
}
}

String fileString = file.toString().substring(scriptsPathLength);
if (fileString.isEmpty())
return;
Expand Down