Windows cannot open any files or folders
Describe the bug Windows cannot open any files or folders
To Reproduce
Run spf, find a folder, use the E shortcut key to not open
Expected behavior
Open this folder using a file manager
System information (please complete the following information):
- OS: 10.0.22631 Build 22631
- Superfile Version v1.1.5
The issue is in openFileWithEditor() / openDirectoryWithEditor()
On windows it should launch default handler app for a file like e.g.:
cmd := exec.Command("cmd", "/c", "start", absPath)
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to open file: %w", err)
}
or:
verb := windows.StringToUTF16Ptr("open")
file := windows.StringToUTF16Ptr(absPath)
// ShellExecute returns an instance handle, but we don't need it
ret, err := windows.ShellExecute(0, verb, file, nil, nil, windows.SW_SHOW)
if ret <= 32 { // According to Windows API documentation, return values <= 32 indicate an error
if err != nil {
return fmt.Errorf("failed to open file: %w", err)
}
return fmt.Errorf("failed to open file: error code %d", ret)
}
For folders it's more tricky because the default handler would be file explorer, not an editor.
One option is to detect handler for .txt files by reading registry and launch that program with directory but not editor support directory. E.g. notepad doesn't handle directories but vscode does.
Able to reproduce it with spf v1.1.7.1 and with Windows 11 Home 24H2 - build 26100.2894
For both files and directories, 'e' and 'E' are not working. Right arrow works as expected.
@p1g3 Thanks for the bug report. This has been fixed. Can you do a local build spf from the main branch and see if the issue if fixed for you ?
@p1g3 Closing this. Please feel free to reopen if you still face the issue.