Hi,
Thank you for developing TreeViewer — it's a great tool for phylogenetic tree visualisation.
I noticed an issue on macOS when opening tree files by double-clicking them in Finder. If the file path contains non-ASCII characters (such as Chinese characters) or spaces, TreeViewer shows the following error:
The file type is not supported by any of the current installed modules!
The same file opens correctly when placed in an ASCII-only path, or when opened from the command line with treeviewer /path/to/file.tree.
Steps to reproduce:
- Place a valid
.tree, .nex, or .tre file in a path like /Users/username/下载/test.tree or /Users/username/test folder/test.tree.
- Double-click the file in Finder.
- TreeViewer launches and shows the unsupported file type error.
Expected behavior:
The file should open normally, since the format itself is valid.
Root cause:
In src/TreeViewer/CoreClasses/MacOSFileOpener.cs, the file URL is converted using uri.AbsolutePath, which URL-encodes non-ASCII characters. For example, /Users/username/下载/test.tree becomes /Users/username/%E4%B8%8B%E8%BD%BD/test.tree, which does not exist on the filesystem. The file type detection modules then fail to read the file and return a support score of 0, leading to the misleading error message.
Suggested fix:
Replace uri.AbsolutePath with uri.LocalPath in both LoadFile calls within MacOSFileOpener.cs. uri.LocalPath returns the properly decoded local filesystem path.
Uri uri = new Uri(url);
if (uri.IsFile)
{
string localPath = uri.LocalPath;
if (GlobalSettings.Settings.MainWindows.Count > 0)
{
await GlobalSettings.Settings.MainWindows[0].LoadFile(localPath, false);
}
else
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
await mainWindow.LoadFile(localPath, false);
}
}
Hi,
Thank you for developing TreeViewer — it's a great tool for phylogenetic tree visualisation.
I noticed an issue on macOS when opening tree files by double-clicking them in Finder. If the file path contains non-ASCII characters (such as Chinese characters) or spaces, TreeViewer shows the following error:
The same file opens correctly when placed in an ASCII-only path, or when opened from the command line with
treeviewer /path/to/file.tree.Steps to reproduce:
.tree,.nex, or.trefile in a path like/Users/username/下载/test.treeor/Users/username/test folder/test.tree.Expected behavior:
The file should open normally, since the format itself is valid.
Root cause:
In
src/TreeViewer/CoreClasses/MacOSFileOpener.cs, the file URL is converted usinguri.AbsolutePath, which URL-encodes non-ASCII characters. For example,/Users/username/下载/test.treebecomes/Users/username/%E4%B8%8B%E8%BD%BD/test.tree, which does not exist on the filesystem. The file type detection modules then fail to read the file and return a support score of 0, leading to the misleading error message.Suggested fix:
Replace
uri.AbsolutePathwithuri.LocalPathin bothLoadFilecalls withinMacOSFileOpener.cs.uri.LocalPathreturns the properly decoded local filesystem path.