MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / resolveDefaultSaveUri

Function resolveDefaultSaveUri

src/utils/export.ts:29–57  ·  view source on GitHub ↗
(
	context: ExportContext,
	configKey: string,
	fileName: string,
	options: ExportOptions = {},
)

Source from the content-addressed store, hash-verified

27 * 4. Default to just the filename (user's home/cwd)
28 */
29export function resolveDefaultSaveUri(
30 context: ExportContext,
31 configKey: string,
32 fileName: string,
33 options: ExportOptions = {},
34): vscode.Uri {
35 const { useWorkspace = true, fallbackDir } = options
36 const lastExportPath = context.getValue(configKey) as string | undefined
37
38 if (lastExportPath) {
39 // Use the directory from the last export
40 const lastDir = path.dirname(lastExportPath)
41 return vscode.Uri.file(path.join(lastDir, fileName))
42 } else {
43 // Try workspace if enabled
44 const workspaceFolders = vscode.workspace.workspaceFolders
45 if (useWorkspace && workspaceFolders && workspaceFolders.length > 0) {
46 return vscode.Uri.file(path.join(workspaceFolders[0].uri.fsPath, fileName))
47 }
48
49 // Fallback
50 if (fallbackDir) {
51 return vscode.Uri.file(path.join(fallbackDir, fileName))
52 }
53
54 // Default to cwd/home
55 return vscode.Uri.file(fileName)
56 }
57}
58
59export async function saveLastExportPath(context: ExportContext, configKey: string, uri: vscode.Uri) {
60 await context.setValue(configKey, uri.fsPath)

Callers 4

webviewMessageHandlerFunction · 0.90
exportTaskWithIdMethod · 0.90
importSettingsFunction · 0.90
exportSettingsFunction · 0.90

Calls 2

fileMethod · 0.80
getValueMethod · 0.65

Tested by

no test coverage detected