From f71b937c4665719d613ed2b0028cf8b533e61a53 Mon Sep 17 00:00:00 2001 From: deirn Date: Sun, 29 Dec 2024 01:07:17 +0700 Subject: [PATCH] relativize gracefully --- .../java/mcp/mobius/waila/config/PluginConfig.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/mcp/mobius/waila/config/PluginConfig.java b/src/main/java/mcp/mobius/waila/config/PluginConfig.java index abb3a2ce..92688669 100644 --- a/src/main/java/mcp/mobius/waila/config/PluginConfig.java +++ b/src/main/java/mcp/mobius/waila/config/PluginConfig.java @@ -53,9 +53,16 @@ public enum PluginConfig implements IPluginConfig { if (language.has(descKey)) sb.append('\n').append(language.getOrDefault(descKey)); if (type.equals(ConfigEntry.PATH)) { - var configPath = (Path) entry.getDefaultValue(); + var parentPath = PATH.getParent().toAbsolutePath(); + var configPath = ((Path) entry.getDefaultValue()).toAbsolutePath(); + try { + configPath = parentPath.relativize(configPath); + } catch (IllegalArgumentException e) { + // no-op + } + sb.append("\n").append(language.getOrDefault(Tl.Json5.Config.Plugin.CUSTOM_FILE)); - sb.append("\n").append(PATH.getParent().relativize(configPath)); + sb.append("\n").append(configPath); return sb.toString(); }