|
9 | 9 | Uri, |
10 | 10 | window, |
11 | 11 | workspace, |
| 12 | + type WorkspaceConfiguration, |
12 | 13 | } from "vscode"; |
13 | 14 | import * as net from "net"; |
14 | 15 | import * as fs from "fs"; |
@@ -96,17 +97,7 @@ export async function activate(context: ExtensionContext) { |
96 | 97 | config.get<string>("VModer.GameRootPath") || config.get<string>("cwtools.cache.hoi4"); |
97 | 98 |
|
98 | 99 | 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); |
110 | 101 | } |
111 | 102 |
|
112 | 103 | // 控制语言客户端的选项 |
@@ -175,6 +166,20 @@ export async function activate(context: ExtensionContext) { |
175 | 166 | ); |
176 | 167 | } |
177 | 168 |
|
| 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 | + |
178 | 183 | function updateStatusBarItem(statusBarItem: StatusBarItem, client: LanguageClient) { |
179 | 184 | if (client.isRunning()) { |
180 | 185 | statusBarItem.text = "$(notebook-state-success) VModer"; |
|
0 commit comments