From 5f803a2206a28c0b6f85f616943507d878655588 Mon Sep 17 00:00:00 2001 From: Mirella de Medeiros Date: Mon, 30 Oct 2023 12:56:15 -0300 Subject: [PATCH] fix devtracker crash on unexpected search --- .../panelControllers/trackerPanelController.ts | 12 +++++++++--- src/panel/components/tracker/Search.tsx | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/extension/panelControllers/trackerPanelController.ts b/src/extension/panelControllers/trackerPanelController.ts index a527bdd..67a4762 100644 --- a/src/extension/panelControllers/trackerPanelController.ts +++ b/src/extension/panelControllers/trackerPanelController.ts @@ -266,22 +266,28 @@ export default class TrackerPanelController extends PanelControllerBase< return; } + var success = false; try { const block = await this.blockchainMonitor.getBlock(query, false); if (block) { request.selectBlock = block.hash; + success = true; } } catch { try { const tx = await this.getTransaction(query.toLowerCase(), false); if (tx) { request.selectTransaction = tx.tx.hash; + success = true; } } catch { - vscode.window.showErrorMessage( - `Could not retrieve block or transaction with hash ${query}` - ); + success = false; } } + if (!success) { + vscode.window.showErrorMessage( + `Could not retrieve block or transaction with hash ${query}` + ); + } } } diff --git a/src/panel/components/tracker/Search.tsx b/src/panel/components/tracker/Search.tsx index ef09349..e0e0afe 100644 --- a/src/panel/components/tracker/Search.tsx +++ b/src/panel/components/tracker/Search.tsx @@ -35,7 +35,8 @@ export default function Search({ searchHistory, onSearch }: Props) { return (
{ + onSubmit={(e) => { + e.preventDefault(); onSearch(searchInput); setSearchInput(""); }}