multi definition of association

This commit is contained in:
Radek Davidek 2026-01-20 19:16:12 +01:00
parent e585341b69
commit c1e2bce59c

View File

@ -1248,7 +1248,15 @@ public class FilePanelTab extends JPanel {
patterns.sort((a, b) -> Integer.compare(b.length(), a.length()));
for (String pattern : patterns) {
String glob = pattern;
String fullCommand = associations.get(pattern);
// Support multiple patterns separated by semicolon (e.g. "jpg;png;gif")
String[] subPatterns = pattern.split(";");
boolean matched = false;
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;
@ -1257,17 +1265,21 @@ public class FilePanelTab extends JPanel {
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);
command = fullCommand;
matched = true;
break;
}
} catch (Exception ignore) {
// Fallback for simple extension match if glob is invalid
if (name.toLowerCase().endsWith("." + pattern.toLowerCase())) {
command = associations.get(pattern);
if (name.toLowerCase().endsWith("." + glob.toLowerCase())) {
command = fullCommand;
matched = true;
break;
}
}
}
if (matched) break;
}
if (command != null && !command.trim().isEmpty()) {
String fullPath = file.getAbsolutePath();