Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/core/prompts/instructions/create-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import * as path from "path"
import * as vscode from "vscode"

import { GlobalFileNames } from "../../../shared/globalFileNames"
import { getSettingsDirectoryPath } from "../../../utils/storage"

export async function createModeInstructions(context: vscode.ExtensionContext | undefined): Promise<string> {
if (!context) throw new Error("Missing VSCode Extension Context")

const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
// Use getSettingsDirectoryPath to honor custom storage path setting
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
const customModesPath = path.join(settingsDir, GlobalFileNames.customModes)

return `
Expand Down
8 changes: 4 additions & 4 deletions src/utils/globalContext.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { mkdir } from "fs/promises"
import { join } from "path"
import { ExtensionContext } from "vscode"
import { getSettingsDirectoryPath } from "./storage"

export async function getGlobalFsPath(context: ExtensionContext): Promise<string> {
return context.globalStorageUri.fsPath
}

export async function ensureSettingsDirectoryExists(context: ExtensionContext): Promise<string> {
const settingsDir = join(context.globalStorageUri.fsPath, "settings")
await mkdir(settingsDir, { recursive: true })
// Use getSettingsDirectoryPath to honor custom storage path setting
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)
// getSettingsDirectoryPath already creates the directory, so no need to call mkdir
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment necessary? The implementation is clear enough that getSettingsDirectoryPath handles directory creation. The comment might become outdated if the implementation changes.

return settingsDir
}
4 changes: 3 additions & 1 deletion src/utils/migrateSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from "path"
import * as fs from "fs/promises"
import { fileExistsAtPath } from "./fs"
import { GlobalFileNames } from "../shared/globalFileNames"
import { getSettingsDirectoryPath } from "./storage"
import * as yaml from "yaml"

const deprecatedCustomModesJSONFilename = "custom_modes.json"
Expand All @@ -26,7 +27,8 @@ export async function migrateSettings(
]

try {
const settingsDir = path.join(context.globalStorageUri.fsPath, "settings")
// Use getSettingsDirectoryPath to honor custom storage path setting
const settingsDir = await getSettingsDirectoryPath(context.globalStorageUri.fsPath)

// Check if settings directory exists first
if (!(await fileExistsAtPath(settingsDir))) {
Expand Down
Loading