From b88ebe495aaf255065ae12a8dae14de39f13dad4 Mon Sep 17 00:00:00 2001 From: tom goriunov Date: Tue, 11 Feb 2025 10:21:41 +0100 Subject: [PATCH] =?UTF-8?q?Contract=20source=20code:=20the=20code=20for=20?= =?UTF-8?q?the=20empty=20contract=20is=20not=20displaye=E2=80=A6=20(#2569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contract source code: the code for the empty contract is not displayed because of a JS crash Fixes #2568 --- ui/shared/monaco/CodeEditor.tsx | 2 +- ui/shared/monaco/utils/addMainContractCodeDecoration.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/shared/monaco/CodeEditor.tsx b/ui/shared/monaco/CodeEditor.tsx index 0d2cca32c3..35313e2128 100644 --- a/ui/shared/monaco/CodeEditor.tsx +++ b/ui/shared/monaco/CodeEditor.tsx @@ -252,7 +252,7 @@ const CodeEditor = ({ data, remappings, libraries, language, mainFile, contractN }), [ editorWidth, themeColors, borderRadius ]); const renderErrorScreen = React.useCallback(() => { - return
Oops! Something went wrong!
; + return
Oops! Something went wrong!
; }, [ themeColors ]); if (data.length === 1) { diff --git a/ui/shared/monaco/utils/addMainContractCodeDecoration.ts b/ui/shared/monaco/utils/addMainContractCodeDecoration.ts index 7ea7fadf9f..5a98dbd11b 100644 --- a/ui/shared/monaco/utils/addMainContractCodeDecoration.ts +++ b/ui/shared/monaco/utils/addMainContractCodeDecoration.ts @@ -47,7 +47,7 @@ export default function addMainContractCodeDecoration(model: monaco.editor.IText .findMatches(`^\\}`, lastLineRange, true, false, null, true) .sort(sortByEndLineNumberAsc); - const restDecoration: monaco.editor.IModelDeltaDecoration = { + const restDecoration: monaco.editor.IModelDeltaDecoration | undefined = lastLineMatch ? { range: { startLineNumber: firstLineMatch.range.startLineNumber + 1, endLineNumber: lastLineMatch.range.startLineNumber, @@ -59,8 +59,8 @@ export default function addMainContractCodeDecoration(model: monaco.editor.IText className: '.main-contract-body', marginClassName: '.main-contract-body', }, - }; + } : undefined; editor.updateOptions({ glyphMargin: true }); - model.deltaDecorations([], [ firstLineDecoration, restDecoration ]); + model.deltaDecorations([], [ firstLineDecoration, restDecoration ].filter(Boolean)); }