From 51358ce77da1a4c946d5298956725f1bbdc445ba Mon Sep 17 00:00:00 2001 From: Emil Valeev Date: Sun, 19 Nov 2023 00:10:40 +0600 Subject: [PATCH] fix(vscode): improve logging more --- web/src/extension.ts | 25 +++++++++++++++---------- web/src/webview.ts | 1 - web/webview/src/App.tsx | 8 -------- web/webview/src/hooks/use_file_state.ts | 6 +++++- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/web/src/extension.ts b/web/src/extension.ts index 700a0c79..55973204 100644 --- a/web/src/extension.ts +++ b/web/src/extension.ts @@ -30,7 +30,10 @@ export async function activate(context: ExtensionContext) { // Listen to language server events and update current indexed module state let initialIndex: unknown; lspClient.onNotification("neva/workdir_indexed", (newIndex: unknown) => { - console.info("workdir has been successfully indexed", newIndex); + console.info( + "language-server notification - workdir has been indexed", + newIndex + ); initialIndex = newIndex; }); @@ -64,7 +67,6 @@ function getPreviewCommand( return () => { const initialIndex = getInitialIndex(); - console.info("webview triggered: ", { initialIndex }); if (!window.activeTextEditor) { @@ -72,12 +74,6 @@ function getPreviewCommand( return; } - if (!initialIndex) { - window.showWarningMessage( - "Working directory is not indexed yet. Just wait for a little bit." - ); - } - const column = window.activeTextEditor ? window.activeTextEditor.viewColumn : undefined; @@ -103,10 +99,9 @@ function getPreviewCommand( panel.webview.html = getWebviewContent(panel.webview, context.extensionUri); - sendMsgToWebview(panel, window.activeTextEditor!.document, initialIndex); - onWebviewCreated((update: unknown) => { sendMsgToWebview(panel!, window.activeTextEditor!.document, update); + console.info("upd message sent to webview", initialIndex); }); panel.onDidDispose( @@ -118,5 +113,15 @@ function getPreviewCommand( ); console.info("existing panel not found, new panel has been created"); + + if (!initialIndex) { + window.showWarningMessage( + "Working directory is not indexed yet. Just wait for a little bit." + ); + return; + } + + sendMsgToWebview(panel, window.activeTextEditor!.document, initialIndex); + console.info("initial message to webview", initialIndex); }; } diff --git a/web/src/webview.ts b/web/src/webview.ts index a575a24d..ac5db409 100644 --- a/web/src/webview.ts +++ b/web/src/webview.ts @@ -59,7 +59,6 @@ export function sendMsgToWebview( programState: parsedProgram, isDarkTheme: window.activeColorTheme.kind === ColorThemeKind.Dark, }); - console.log("message to webview sent: ", parsedProgram); } export function getNonce() { diff --git a/web/webview/src/App.tsx b/web/webview/src/App.tsx index d5262b50..978f423e 100644 --- a/web/webview/src/App.tsx +++ b/web/webview/src/App.tsx @@ -18,14 +18,6 @@ export default function App() { return (
- - USE - TYPES - CONST - INTERFACES - COMPONENTS - - diff --git a/web/webview/src/hooks/use_file_state.ts b/web/webview/src/hooks/use_file_state.ts index 3767db1b..48b88c46 100644 --- a/web/webview/src/hooks/use_file_state.ts +++ b/web/webview/src/hooks/use_file_state.ts @@ -63,7 +63,11 @@ export function useFileState(): FileState { }; // if tab opened first time and there were no updates from vscode yet - if (state === undefined) { + if (!state) { + return result; + } + + if (!state.programState.packages) { return result; }