Skip to content

Commit 7b033dc

Browse files
authored
Merge pull request #1920 from jeff66ruan/wip/userConfigEdn
Ensure user Calva config.edn path exists before creating the file
2 parents a64748b + 51c8ff6 commit 7b033dc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changes to Calva.
44

55
## [Unreleased]
66

7+
- Fix: [Calva: Open REPL snippets User config.edn couldn't create the file if parent folders doesn't exist](https://github.com/BetterThanTomorrow/calva/issues/1916)
78
- Calva development: [Use requirements.txt in CI for publishing docs](https://github.com/BetterThanTomorrow/calva/issues/1913)
89
- Bump deps.clj to v1.11.1.1182
910
- Fix: [Drag sexps in value part of doseq sometimes jumps 2 sexps instead of 1](https://github.com/BetterThanTomorrow/calva/issues/1914)

src/config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from 'vscode';
22
import * as os from 'os';
33
import * as fs from 'fs';
4+
import * as path from 'path';
45
import { customREPLCommandSnippet } from './evaluate';
56
import { ReplConnectSequence } from './nrepl/connectSequence';
67
import { PrettyPrintingOptions } from './printer';
@@ -42,13 +43,13 @@ const userConfigFileUri = vscode.Uri.joinPath(
4243
);
4344

4445
async function openCalvaConfigEdn() {
45-
const configPath = state.resolvePath('.calva/config.edn');
4646
return fs.promises
4747
.access(userConfigFileUri.fsPath, fs.constants.F_OK)
4848
.then(async () => await vscode.window.showTextDocument(userConfigFileUri))
4949
.catch(async (error) => {
5050
if (error.code === 'ENOENT') {
5151
try {
52+
await fs.promises.mkdir(path.dirname(userConfigFileUri.fsPath), { recursive: true });
5253
await fs.promises.writeFile(
5354
userConfigFileUri.fsPath,
5455
'{:customREPLHoverSnippets []\n :customREPLCommandSnippets []}'
@@ -58,9 +59,7 @@ async function openCalvaConfigEdn() {
5859
console.error('Error creating user config.edn', error);
5960
}
6061
} else {
61-
void vscode.window.showErrorMessage(
62-
'Could not find a config.edn file in the workspace. Please create one and try again.'
63-
);
62+
void vscode.window.showErrorMessage('Could not open user config.edn. ' + error.message);
6463
}
6564
});
6665
}

0 commit comments

Comments
 (0)