Skip to content

Commit 87ee3e5

Browse files
committed
fix: 选择游戏根目录时可能无法成功保存
1 parent cf63a7a commit 87ee3e5

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

VModer.Extensions/client/extension/extension.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Uri,
1010
window,
1111
workspace,
12+
type WorkspaceConfiguration,
1213
} from "vscode";
1314
import * as net from "net";
1415
import * as fs from "fs";
@@ -96,17 +97,7 @@ export async function activate(context: ExtensionContext) {
9697
config.get<string>("VModer.GameRootPath") || config.get<string>("cwtools.cache.hoi4");
9798

9899
if (gameRootFolderPath === undefined || gameRootFolderPath === "") {
99-
await window.showWarningMessage(l10n.t("SelectGameRootPath"), l10n.t("SelectFolder"));
100-
const uri = await window.showOpenDialog({
101-
canSelectFiles: false,
102-
canSelectFolders: true,
103-
canSelectMany: false,
104-
openLabel: l10n.t("SelectFolder"),
105-
});
106-
if (uri && uri[0]) {
107-
config.update("VModer.GameRootPath", uri[0].fsPath, true);
108-
}
109-
await window.showInformationMessage(l10n.t("MustRestart"));
100+
await pickGameRootFolderPath(config);
110101
}
111102

112103
// 控制语言客户端的选项
@@ -175,6 +166,20 @@ export async function activate(context: ExtensionContext) {
175166
);
176167
}
177168

169+
async function pickGameRootFolderPath(config: WorkspaceConfiguration) {
170+
await window.showWarningMessage(l10n.t("SelectGameRootPath"), l10n.t("SelectFolder"));
171+
const uri = await window.showOpenDialog({
172+
canSelectFiles: false,
173+
canSelectFolders: true,
174+
canSelectMany: false,
175+
openLabel: l10n.t("SelectFolder"),
176+
});
177+
if (uri && uri[0]) {
178+
await config.update("VModer.GameRootPath", uri[0].fsPath, true);
179+
}
180+
await window.showInformationMessage(l10n.t("MustRestart"));
181+
}
182+
178183
function updateStatusBarItem(statusBarItem: StatusBarItem, client: LanguageClient) {
179184
if (client.isRunning()) {
180185
statusBarItem.text = "$(notebook-state-success) VModer";

0 commit comments

Comments
 (0)