mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
fix: allow opening files without workspace root (#1054)
* fix: allow opening files without workspace root The openFile function in open-file.ts was requiring a workspace root to be present, which prevented opening global files (like MCP settings) when no workspace was open. Modified the function to handle absolute paths without this requirement. Previously, trying to open MCP settings in a new window without a workspace would error with "Could not open file: No workspace root found". Now the function properly handles both workspace-relative and absolute paths, allowing global settings files to be accessed in any context. Changes: - Removed workspace root requirement in openFile - Added fallback for relative paths when no workspace is present * fix: update openFile function to use provided path without modification --------- Co-authored-by: Roo Code <support@roo.vet> Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
This commit is contained in:
parent
0f64849542
commit
3d129e8a89
1 changed files with 7 additions and 5 deletions
|
|
@ -29,12 +29,14 @@ export async function openFile(filePath: string, options: OpenFileOptions = {})
|
|||
try {
|
||||
// Get workspace root
|
||||
const workspaceRoot = getWorkspacePath()
|
||||
if (!workspaceRoot) {
|
||||
throw new Error("No workspace root found")
|
||||
}
|
||||
|
||||
// If path starts with ./, resolve it relative to workspace root
|
||||
const fullPath = filePath.startsWith("./") ? path.join(workspaceRoot, filePath.slice(2)) : filePath
|
||||
// If path starts with ./, resolve it relative to workspace root if available
|
||||
// Otherwise, use the path as provided without modification
|
||||
const fullPath = filePath.startsWith("./")
|
||||
? workspaceRoot
|
||||
? path.join(workspaceRoot, filePath.slice(2))
|
||||
: filePath
|
||||
: filePath
|
||||
|
||||
const uri = vscode.Uri.file(fullPath)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue