Skip to content

Commit 00e9bf2

Browse files
feat(vscode): Add a help button in the language server error dialog box (#260)
* feat(vscode): Add a help button in the language server error dialog box - Add a "Help" button in the warning dialog box when the language server fails to start * chore: fix lint --------- Co-authored-by: groupguanfang <[email protected]>
1 parent 8c7ae98 commit 00e9bf2

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

packages/vscode/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"sdk.error.downloadOrChoiceSdkPath": "Download or choose a OpenHarmony SDK path",
108108
"sdk.error.languageServerError": "ArkTS Language Server Start Failed, please try to restart the IDE or check the OpenHarmony SDK path is correct. Error detail: {0}",
109109
"sdk.error.validSdkPath": "OpenHarmony SDK path is not set in global IDE configuration and local workspace local.properties file, the ETS Language Server will not work properly.",
110+
"sdk.error.helpLabel": "Help",
110111
"sdk.guess.install.no": "No",
111112
"sdk.guess.install.title": "The current workspace likely use OpenHarmony SDK {0}, are you want to install this SDK?",
112113
"sdk.guess.install.yes": "Yes",

packages/vscode/package.nls.zh-cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"sdk.error.downloadOrChoiceSdkPath": "下载或选择一个 OpenHarmony SDK 路径",
108108
"sdk.error.languageServerError": "ArkTS 语言服务器启动失败, 请尝试重启 IDE 或检查 OpenHarmony SDK 路径是否正确。错误详情: {0}",
109109
"sdk.error.validSdkPath": "OpenHarmony SDK 路径未设置在全局 IDE 配置和本地工作区 local.properties 文件中,ETS 语言服务器可能将无法正常工作。",
110+
"sdk.error.helpLabel": "帮助",
110111
"sdk.guess.install.no": "",
111112
"sdk.guess.install.title": "当前工作区可能使用 OpenHarmony SDK {0},您是否想要安装此 SDK?",
112113
"sdk.guess.install.yes": "",

packages/vscode/src/context/server-context.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,28 @@ export abstract class LanguageServerContext extends AbstractWatcher implements I
4444
console.error(error)
4545
const choiceSdkPath = this.translator.t('sdk.error.choiceSdkPathMasually')
4646
const downloadOrChoiceSdkPath = this.translator.t('sdk.error.downloadOrChoiceSdkPath')
47+
const helpLabel = this.translator.t('sdk.error.helpLabel')
4748
const detail = this.errorToString(error)
48-
const result = await vscode.window.showWarningMessage(
49-
'ArkTS Language Server Warning',
50-
{ modal: true, detail },
51-
choiceSdkPath,
52-
downloadOrChoiceSdkPath,
53-
)
49+
50+
// 循环显示对话框,直到用户选择操作
51+
let result: string | undefined
52+
do {
53+
result = await vscode.window.showWarningMessage(
54+
'ArkTS Language Server Warning',
55+
{ modal: true, detail },
56+
choiceSdkPath,
57+
downloadOrChoiceSdkPath,
58+
helpLabel,
59+
)
60+
61+
if (result === helpLabel) {
62+
// 打开帮助文档,但不关闭对话框
63+
const helpUrl = vscode.Uri.parse('https://arkcode.dev/arkts/install/#方法一-选择自带在-deveco-studio-中的-sdk-推荐')
64+
await vscode.env.openExternal(helpUrl)
65+
// 继续循环,重新显示对话框
66+
result = undefined
67+
}
68+
} while (result === undefined)
5469

5570
if (result === choiceSdkPath) {
5671
const [sdkPath] = await vscode.window.showOpenDialog({

0 commit comments

Comments
 (0)