File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ export class VulncheckProvider {
223223 }
224224
225225 private async runInternal ( goCtx : GoExtensionContext ) {
226- const pick = await vscode . window . showQuickPick ( [ 'Current Package' , 'Workspace' ] ) ;
226+ const pick = await vscode . window . showQuickPick ( [ 'Current Package' , 'Current Module' , ' Workspace'] ) ;
227227 let dir , pattern : string ;
228228 const document = vscode . window . activeTextEditor ?. document ;
229229 switch ( pick ) {
@@ -241,6 +241,14 @@ export class VulncheckProvider {
241241 dir = path . dirname ( document . fileName ) ;
242242 pattern = '.' ;
243243 break ;
244+ case 'Current Module' :
245+ dir = await moduleDir ( document ) ;
246+ if ( ! dir ) {
247+ vscode . window . showErrorMessage ( 'vulncheck error: no current module' ) ;
248+ return ;
249+ }
250+ pattern = './...' ;
251+ break ;
244252 case 'Workspace' :
245253 dir = await this . activeDir ( ) ;
246254 pattern = './...' ;
@@ -308,6 +316,18 @@ export class VulncheckProvider {
308316 }
309317}
310318
319+ async function moduleDir ( document : vscode . TextDocument | undefined ) {
320+ const docDir = document && document . fileName && path . dirname ( document . fileName ) ;
321+ if ( ! docDir ) {
322+ return ;
323+ }
324+ const modFile = await getGoModFile ( vscode . Uri . file ( docDir ) ) ;
325+ if ( ! modFile ) {
326+ return ;
327+ }
328+ return path . dirname ( modFile ) ;
329+ }
330+
311331// run `gopls vulncheck`.
312332export async function vulncheck (
313333 goCtx : GoExtensionContext ,
You can’t perform that action at this time.
0 commit comments