Skip to content

Commit e5bda9f

Browse files
committed
PR feedback
1 parent f39b520 commit e5bda9f

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/core/config/CustomModesManager.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ export class CustomModesManager {
181181

182182
this.disposables.push(settingsWatcher.onDidChange(handleSettingsChange))
183183
this.disposables.push(settingsWatcher.onDidCreate(handleSettingsChange))
184+
this.disposables.push(settingsWatcher.onDidDelete(handleSettingsChange))
184185
this.disposables.push(settingsWatcher)
185186

186-
// Watch .roomodes file if it exists
187-
const roomodesPath = await this.getWorkspaceRoomodes()
188-
189-
if (roomodesPath) {
187+
// Watch .roomodes file - watch the path even if it doesn't exist yet
188+
const workspaceFolders = vscode.workspace.workspaceFolders
189+
if (workspaceFolders && workspaceFolders.length > 0) {
190+
const workspaceRoot = getWorkspacePath()
191+
const roomodesPath = path.join(workspaceRoot, ROOMODES_FILENAME)
190192
const roomodesWatcher = vscode.workspace.createFileSystemWatcher(roomodesPath)
191193

192194
const handleRoomodesChange = async () => {
@@ -203,19 +205,21 @@ export class CustomModesManager {
203205
}
204206
}
205207

206-
roomodesWatcher.onDidChange(handleRoomodesChange)
207-
roomodesWatcher.onDidCreate(handleRoomodesChange)
208-
roomodesWatcher.onDidDelete(async () => {
209-
// When .roomodes is deleted, refresh with only settings modes
210-
try {
211-
const settingsModes = await this.loadModesFromFile(settingsPath)
212-
await this.context.globalState.update("customModes", settingsModes)
213-
this.clearCache()
214-
await this.onUpdate()
215-
} catch (error) {
216-
console.error(`[CustomModesManager] Error handling .roomodes file deletion:`, error)
217-
}
218-
})
208+
this.disposables.push(roomodesWatcher.onDidChange(handleRoomodesChange))
209+
this.disposables.push(roomodesWatcher.onDidCreate(handleRoomodesChange))
210+
this.disposables.push(
211+
roomodesWatcher.onDidDelete(async () => {
212+
// When .roomodes is deleted, refresh with only settings modes
213+
try {
214+
const settingsModes = await this.loadModesFromFile(settingsPath)
215+
await this.context.globalState.update("customModes", settingsModes)
216+
this.clearCache()
217+
await this.onUpdate()
218+
} catch (error) {
219+
console.error(`[CustomModesManager] Error handling .roomodes file deletion:`, error)
220+
}
221+
}),
222+
)
219223
this.disposables.push(roomodesWatcher)
220224
}
221225
}
@@ -339,7 +343,7 @@ export class CustomModesManager {
339343
await fs.writeFile(filePath, yaml.stringify(settings), "utf-8")
340344
}
341345

342-
public async refreshMergedState(): Promise<void> {
346+
private async refreshMergedState(): Promise<void> {
343347
const settingsPath = await this.getCustomModesFilePath()
344348
const roomodesPath = await this.getWorkspaceRoomodes()
345349

0 commit comments

Comments
 (0)