Skip to content

Commit fd959bf

Browse files
committed
fix: fix set workspace setting
1 parent 5e79857 commit fd959bf

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1212
"typescript.tsc.autoDetect": "off",
1313
"editor.formatOnSave": true
14-
}
14+
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"publisher": "cnblogs",
99
"repository": {
1010
"type": "github",
11-
"url": "https://github.com",
12-
"directory": "cnblogs/vscode-cnb"
11+
"url": "https://github.com/cnblogs/vscode-cnb"
1312
},
1413
"keywords": [
1514
"cnblogs",
@@ -211,7 +210,7 @@
211210
"properties": {
212211
"vscode-cnb.workspace": {
213212
"default": "~/Documents/Cnblogs",
214-
"scope": "resource",
213+
"scope": "application",
215214
"type": "string",
216215
"editPresentation": "singlelineText",
217216
"markdownDescription": "存放markdown博文的文件夹, 默认为`~/Documents/Cnblogs`, 当检测到vscode处于此工作空间时, 可以vscode-cnb插件编辑已有博文, 也可以将本地markdown文件保存到博客园"

src/commands/set-workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export const setWorkspace = async () => {
1515
return;
1616
}
1717

18-
Settings.workspaceUri = input;
18+
await Settings.setWorkspaceUri(input);
1919
AlertService.info(`工作空间成功修改为: "${Settings.workspaceUri.fsPath}"`);
2020
};

src/services/settings.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { homedir } from 'os';
22
import * as fs from 'fs';
3-
import { Uri, workspace } from 'vscode';
3+
import { ConfigurationTarget, Uri, workspace } from 'vscode';
44
import { globalState } from './global-state';
55

66
export class Settings {
@@ -15,13 +15,13 @@ export class Settings {
1515
: Uri.joinPath(Uri.file(homedir()), 'Documents', 'Cnblogs');
1616
}
1717

18-
static set workspaceUri(value: Uri) {
18+
static async setWorkspaceUri(value: Uri) {
1919
if (!value.fsPath || !(value.scheme === 'file')) {
2020
throw Error('Invalid uri');
2121
}
2222
if (!fs.existsSync(value.fsPath)) {
2323
throw Error(`Folder "${value.fsPath}" not exist`);
2424
}
25-
this.configuration.update('workspace', value.fsPath);
25+
await this.configuration.update('workspace', value.fsPath, ConfigurationTarget.Global);
2626
}
2727
}

0 commit comments

Comments
 (0)