multi definition of association
This commit is contained in:
parent
e585341b69
commit
c1e2bce59c
@ -1248,7 +1248,15 @@ public class FilePanelTab extends JPanel {
|
|||||||
patterns.sort((a, b) -> Integer.compare(b.length(), a.length()));
|
patterns.sort((a, b) -> Integer.compare(b.length(), a.length()));
|
||||||
|
|
||||||
for (String pattern : patterns) {
|
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 user just provided an extension like "txt", convert to "*.txt"
|
||||||
if (!glob.contains("*") && !glob.contains("?")) {
|
if (!glob.contains("*") && !glob.contains("?")) {
|
||||||
glob = "*." + glob;
|
glob = "*." + glob;
|
||||||
@ -1257,17 +1265,21 @@ public class FilePanelTab extends JPanel {
|
|||||||
try {
|
try {
|
||||||
java.nio.file.PathMatcher matcher = java.nio.file.FileSystems.getDefault().getPathMatcher("glob:" + glob);
|
java.nio.file.PathMatcher matcher = java.nio.file.FileSystems.getDefault().getPathMatcher("glob:" + glob);
|
||||||
if (matcher.matches(java.nio.file.Paths.get(name))) {
|
if (matcher.matches(java.nio.file.Paths.get(name))) {
|
||||||
command = associations.get(pattern);
|
command = fullCommand;
|
||||||
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
// Fallback for simple extension match if glob is invalid
|
// Fallback for simple extension match if glob is invalid
|
||||||
if (name.toLowerCase().endsWith("." + pattern.toLowerCase())) {
|
if (name.toLowerCase().endsWith("." + glob.toLowerCase())) {
|
||||||
command = associations.get(pattern);
|
command = fullCommand;
|
||||||
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (matched) break;
|
||||||
|
}
|
||||||
|
|
||||||
if (command != null && !command.trim().isEmpty()) {
|
if (command != null && !command.trim().isEmpty()) {
|
||||||
String fullPath = file.getAbsolutePath();
|
String fullPath = file.getAbsolutePath();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user