multi definition of association
This commit is contained in:
parent
e585341b69
commit
c1e2bce59c
@ -1248,25 +1248,37 @@ public class FilePanelTab extends JPanel {
|
||||
patterns.sort((a, b) -> Integer.compare(b.length(), a.length()));
|
||||
|
||||
for (String pattern : patterns) {
|
||||
String glob = pattern;
|
||||
// If user just provided an extension like "txt", convert to "*.txt"
|
||||
if (!glob.contains("*") && !glob.contains("?")) {
|
||||
glob = "*." + glob;
|
||||
}
|
||||
String fullCommand = associations.get(pattern);
|
||||
// Support multiple patterns separated by semicolon (e.g. "jpg;png;gif")
|
||||
String[] subPatterns = pattern.split(";");
|
||||
boolean matched = false;
|
||||
|
||||
try {
|
||||
java.nio.file.PathMatcher matcher = java.nio.file.FileSystems.getDefault().getPathMatcher("glob:" + glob);
|
||||
if (matcher.matches(java.nio.file.Paths.get(name))) {
|
||||
command = associations.get(pattern);
|
||||
break;
|
||||
for (String sub : subPatterns) {
|
||||
String glob = sub.trim();
|
||||
if (glob.isEmpty()) continue;
|
||||
|
||||
// If user just provided an extension like "txt", convert to "*.txt"
|
||||
if (!glob.contains("*") && !glob.contains("?")) {
|
||||
glob = "*." + glob;
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
// Fallback for simple extension match if glob is invalid
|
||||
if (name.toLowerCase().endsWith("." + pattern.toLowerCase())) {
|
||||
command = associations.get(pattern);
|
||||
break;
|
||||
|
||||
try {
|
||||
java.nio.file.PathMatcher matcher = java.nio.file.FileSystems.getDefault().getPathMatcher("glob:" + glob);
|
||||
if (matcher.matches(java.nio.file.Paths.get(name))) {
|
||||
command = fullCommand;
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
// Fallback for simple extension match if glob is invalid
|
||||
if (name.toLowerCase().endsWith("." + glob.toLowerCase())) {
|
||||
command = fullCommand;
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matched) break;
|
||||
}
|
||||
|
||||
if (command != null && !command.trim().isEmpty()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user