Skip to content

Commit c1e55c4

Browse files
SoonIterHerringtonDarkholme
authored andcommitted
chore: add document about upgrading
1 parent ccfe6af commit c1e55c4

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/extension/lsp.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { workspace, type ExtensionContext, window, commands, Uri } from 'vscode'
1+
import {
2+
env,
3+
workspace,
4+
type ExtensionContext,
5+
window,
6+
commands,
7+
Uri,
8+
} from 'vscode'
29
import {
310
LanguageClient,
411
type LanguageClientOptions,
@@ -55,6 +62,9 @@ async function applyAllFixes() {
5562
if (!textEditor) {
5663
return
5764
}
65+
if (!client) {
66+
return
67+
}
5868
const textDocument = {
5969
uri: textEditor.document.uri.toString(),
6070
version: textEditor.document.version,
@@ -65,9 +75,21 @@ async function applyAllFixes() {
6575
arguments: [textDocument],
6676
}
6777
client.sendRequest(ExecuteCommandRequest.type, params).then(undefined, () => {
68-
void window.showErrorMessage(
69-
'Failed to apply Ast-grep fixes to the document. Please consider upgrading ast-grep version or opening an issue with steps to reproduce.',
70-
)
78+
const actionButtonName = 'Upgrade Document'
79+
window
80+
.showErrorMessage(
81+
'Failed to apply Ast-grep fixes to the document. Please consider upgrading ast-grep version or opening an issue with steps to reproduce.',
82+
actionButtonName,
83+
)
84+
.then(value => {
85+
if (value === actionButtonName) {
86+
env.openExternal(
87+
Uri.parse(
88+
'https://ast-grep.github.io/guide/quick-start.html#installation',
89+
),
90+
)
91+
}
92+
})
7193
})
7294
}
7395

0 commit comments

Comments
 (0)