@@ -15,6 +15,7 @@ let lastActiveTextEditor: vscode.TextEditor | undefined;
1515let cachedCliVersion = 'Loading...' ;
1616let extensionVersion = 'Loading...' ;
1717let currentPanelState : PanelState | null = null ;
18+ let webviewReady = false ;
1819
1920/**
2021 * Extension activation
@@ -47,10 +48,15 @@ export function activate(context: vscode.ExtensionContext): void {
4748 } ) ;
4849
4950 const openPanelCommand = vscode . commands . registerCommand ( 'sourcemeta-studio.openPanel' , ( ) => {
51+ webviewReady = false ;
5052 panelManager . createOrReveal ( context ) ;
5153 updatePanelContent ( ) ;
5254 } ) ;
5355
56+ const isWebviewReadyCommand = vscode . commands . registerCommand ( 'sourcemeta-studio.isWebviewReady' , ( ) => {
57+ return webviewReady ;
58+ } ) ;
59+
5460 const activeEditorChangeListener = vscode . window . onDidChangeActiveTextEditor ( ( editor ) => {
5561 handleActiveEditorChange ( editor ) ;
5662 } ) ;
@@ -65,6 +71,7 @@ export function activate(context: vscode.ExtensionContext): void {
6571
6672 context . subscriptions . push (
6773 openPanelCommand ,
74+ isWebviewReadyCommand ,
6875 activeEditorChangeListener ,
6976 documentSaveListener
7077 ) ;
@@ -74,6 +81,12 @@ export function activate(context: vscode.ExtensionContext): void {
7481 * Handle messages from the webview
7582 */
7683function handleWebviewMessage ( message : WebviewToExtensionMessage ) : void {
84+ if ( message . command === 'ready' ) {
85+ webviewReady = true ;
86+ console . log ( '[Sourcemeta Studio] Webview ready' ) ;
87+ return ;
88+ }
89+
7790 if ( message . command === 'goToPosition' && lastActiveTextEditor && message . position ) {
7891 const range = errorPositionToRange ( message . position ) ;
7992
0 commit comments