11import * as vscode from "vscode" ;
22
3+ import { logError } from "../log" ;
34import { complete , hover , parse } from "github-actions-parser" ;
45
56import { getGitHubContextForDocumentUri } from "../git/repository" ;
@@ -8,7 +9,7 @@ const WorkflowSelector = {
89 pattern : "**/.github/workflows/*.{yaml,yml}" ,
910} ;
1011
11- export function init ( context : vscode . ExtensionContext ) {
12+ export async function init ( context : vscode . ExtensionContext ) {
1213 // Register auto-complete
1314 vscode . languages . registerCompletionItemProvider ( WorkflowSelector , new WorkflowCompletionItemProvider ( ) , "." ) ;
1415
@@ -19,12 +20,12 @@ export function init(context: vscode.ExtensionContext) {
1920 //
2021 const collection = vscode . languages . createDiagnosticCollection ( "github-actions" ) ;
2122 if ( vscode . window . activeTextEditor ) {
22- updateDiagnostics ( vscode . window . activeTextEditor . document , collection ) ;
23+ await updateDiagnostics ( vscode . window . activeTextEditor . document , collection ) ;
2324 }
2425 context . subscriptions . push (
25- vscode . window . onDidChangeActiveTextEditor ( ( editor ) => {
26+ vscode . window . onDidChangeActiveTextEditor ( async ( editor ) => {
2627 if ( editor ) {
27- updateDiagnostics ( editor . document , collection ) ;
28+ await updateDiagnostics ( editor . document , collection ) ;
2829 }
2930 } )
3031 ) ;
@@ -74,8 +75,7 @@ async function updateDiagnostics(
7475export class WorkflowHoverProvider implements vscode . HoverProvider {
7576 async provideHover (
7677 document : vscode . TextDocument ,
77- position : vscode . Position ,
78- token : vscode . CancellationToken
78+ position : vscode . Position
7979 ) : Promise < null | vscode . Hover > {
8080 try {
8181 const gitHubRepoContext = await getGitHubContextForDocumentUri ( document . uri ) ;
@@ -98,9 +98,15 @@ export class WorkflowHoverProvider implements vscode.HoverProvider {
9898 contents : [ hoverResult ?. description ] ,
9999 } ;
100100 }
101- } catch ( e ) {
101+ } catch ( e : unknown ) {
102102 // TODO: CS: handle
103- debugger ;
103+ // Probably coming up from repository:
104+ // repository.ts:getGitHubContext re-throws
105+ // -> called from repository.ts:getGitHubContextForWorkspaceUri
106+ // -> called from diagnostics.ts:getGitHubContextForDocumentUri
107+ // -> called from diagnostics.ts:provideHover
108+ // -> caught here
109+ logError ( e as Error , "Caught error in provideHover" ) ;
104110 }
105111
106112 return null ;
@@ -110,8 +116,7 @@ export class WorkflowHoverProvider implements vscode.HoverProvider {
110116export class WorkflowCompletionItemProvider implements vscode . CompletionItemProvider {
111117 async provideCompletionItems (
112118 document : vscode . TextDocument ,
113- position : vscode . Position ,
114- cancellationToken : vscode . CancellationToken
119+ position : vscode . Position
115120 ) : Promise < vscode . CompletionItem [ ] > {
116121 try {
117122 const gitHubRepoContext = await getGitHubContextForDocumentUri ( document . uri ) ;
0 commit comments