Skip to content

Commit

Permalink
fix(vscode): improve logging more
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Nov 18, 2023
1 parent e2c55a0 commit 51358ce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
25 changes: 15 additions & 10 deletions web/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down Expand Up @@ -64,20 +67,13 @@ function getPreviewCommand(

return () => {
const initialIndex = getInitialIndex();

console.info("webview triggered: ", { initialIndex });

if (!window.activeTextEditor) {
window.showWarningMessage("You need to open neva file to open preview.");
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;
Expand All @@ -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(
Expand All @@ -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);
};
}
1 change: 0 additions & 1 deletion web/src/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 0 additions & 8 deletions web/webview/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ export default function App() {

return (
<div className="app">
<VSCodePanels style={{ marginBottom: "20px", position: "sticky" }}>
<VSCodePanelTab>USE</VSCodePanelTab>
<VSCodePanelTab>TYPES</VSCodePanelTab>
<VSCodePanelTab>CONST</VSCodePanelTab>
<VSCodePanelTab>INTERFACES</VSCodePanelTab>
<VSCodePanelTab>COMPONENTS</VSCodePanelTab>
</VSCodePanels>

<ImportsView imports={imports} style={{ marginBottom: "20px" }} />

<VSCodeDivider style={{ marginBottom: "20px" }} />
Expand Down
6 changes: 5 additions & 1 deletion web/webview/src/hooks/use_file_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 51358ce

Please sign in to comment.