11import vscode from "vscode"
2+ import { commands } from "./commands"
23import { fetchPackage } from "./utils/packages"
34import { parseDependency } from "./utils/parseDependency"
45import { DIAGNOSTIC_CODE } from "./utils/vars"
@@ -44,15 +45,23 @@ export class PackageJsonCodeActionProvider
4445 return Promise . all ( promises )
4546 }
4647
47- private createAction ( message : string ) {
48+ private createAction (
49+ doc : vscode . TextDocument ,
50+ message : string ,
51+ commandMessage : string
52+ ) {
4853 const edit = new vscode . WorkspaceEdit ( )
4954 const action = new vscode . CodeAction (
5055 message ,
5156 vscode . CodeActionKind . QuickFix
5257 )
5358
5459 action . edit = edit
55- action . isPreferred = true
60+ action . command = {
61+ arguments : [ commandMessage , doc . uri ] ,
62+ command : commands . notify ,
63+ title : "update" ,
64+ }
5665
5766 return [ action , edit ] as const
5867 }
@@ -62,7 +71,11 @@ export class PackageJsonCodeActionProvider
6271 diagnostics : vscode . Diagnostic [ ] ,
6372 message : string
6473 ) {
65- const [ action , edit ] = this . createAction ( message )
74+ const [ action , edit ] = this . createAction (
75+ doc ,
76+ message ,
77+ `Package${ diagnostics . length > 1 ? "s" : "" } updated successfully.`
78+ )
6679 action . diagnostics = diagnostics
6780
6881 await Promise . all (
@@ -78,7 +91,13 @@ export class PackageJsonCodeActionProvider
7891 doc : vscode . TextDocument ,
7992 diagnostic : vscode . Diagnostic
8093 ) {
81- const [ action , edit ] = this . createAction ( "Update package" )
94+ const [ action , edit ] = this . createAction (
95+ doc ,
96+ "Update package" ,
97+ "Package update successfully."
98+ )
99+
100+ action . isPreferred = true
82101 action . diagnostics = [ diagnostic ]
83102
84103 await this . createEdit ( edit , doc , diagnostic . range )
0 commit comments