Repository navigation
fix(ui): ⌘O opens macOS Documents folder instead of workspace directory #2056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -593,6 +593,12 @@ struct cmuxApp: App { | |||||||||||||||||||||||||||||||
| panel.allowsMultipleSelection = false | ||||||||||||||||||||||||||||||||
| panel.title = String(localized: "menu.file.openFolder.panelTitle", defaultValue: "Open Folder") | ||||||||||||||||||||||||||||||||
| panel.prompt = String(localized: "menu.file.openFolder.panelPrompt", defaultValue: "Open") | ||||||||||||||||||||||||||||||||
| if let workspace = activeTabManager.selectedWorkspace { | ||||||||||||||||||||||||||||||||
| let directory = workspace.currentDirectory.trimmingCharacters(in: .whitespacesAndNewlines) | ||||||||||||||||||||||||||||||||
| if !directory.isEmpty, FileManager.default.fileExists(atPath: directory) { | ||||||||||||||||||||||||||||||||
| panel.directoryURL = URL(fileURLWithPath: directory, isDirectory: true) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+596
to
+601
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether `currentDirectory` is guaranteed to always be a directory.
# Expected: assignments/initialization sites should only use directory sources
# (workspace roots, cwd, validated directory paths).
rg -n --type swift -C4 '\b(var|let)\s+currentDirectory\b'
rg -n --type swift -C4 '\bcurrentDirectory\s*='
rg -n --type swift -C4 '\bcurrentDirectory\b.*(URL|path|cwd|workingDirectory)'Repository: manaflow-ai/cmux Length of output: 10968 Ensure At Line 598, the code checks only path existence. If Proposed fix if let workspace = activeTabManager.selectedWorkspace {
let directory = workspace.currentDirectory.trimmingCharacters(in: .whitespacesAndNewlines)
- if !directory.isEmpty, FileManager.default.fileExists(atPath: directory) {
+ var isDirectory: ObjCBool = false
+ if !directory.isEmpty,
+ FileManager.default.fileExists(atPath: directory, isDirectory: &isDirectory),
+ isDirectory.boolValue {
panel.directoryURL = URL(fileURLWithPath: directory, isDirectory: true)
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| if panel.runModal() == .OK, let url = panel.url { | ||||||||||||||||||||||||||||||||
| if let appDelegate = AppDelegate.shared { | ||||||||||||||||||||||||||||||||
| if appDelegate.addWorkspaceInPreferredMainWindow( | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileManager.default.fileExists(atPath:)returnstruefor both files and directories. Ifworkspace.currentDirectoryever resolves to a file path (e.g., due to a stale workspace record), the URL would still be set asisDirectory: trueand passed toNSOpenPanel.directoryURL. Using theisDirectory:variant explicitly confirms the path is a directory before using it:Full suggestion (requires adding
var isDir: ObjCBool = falsebefore the check):Same pattern applies to the equivalent block in
Sources/cmuxApp.swift.