Skip to content

Commit d6c6242

Browse files
tom2drumcarlomigueldy
authored andcommitted
Contract source code: the code for the empty contract is not displaye… (blockscout#2569)
Contract source code: the code for the empty contract is not displayed because of a JS crash Fixes blockscout#2568
1 parent c618326 commit d6c6242

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ui/shared/monaco/CodeEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ const CodeEditor = ({ data, remappings, libraries, language, mainFile, contractN
252252
}), [ editorWidth, themeColors, borderRadius ]);
253253

254254
const renderErrorScreen = React.useCallback(() => {
255-
return <Center bgColor={ themeColors['editor.background'] } w="100%" borderRadius="md">Oops! Something went wrong!</Center>;
255+
return <Center bgColor={ themeColors['editor.background'] } w="100%" h="100%" borderRadius="md">Oops! Something went wrong!</Center>;
256256
}, [ themeColors ]);
257257

258258
if (data.length === 1) {

ui/shared/monaco/utils/addMainContractCodeDecoration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function addMainContractCodeDecoration(model: monaco.editor.IText
4747
.findMatches(`^\\}`, lastLineRange, true, false, null, true)
4848
.sort(sortByEndLineNumberAsc);
4949

50-
const restDecoration: monaco.editor.IModelDeltaDecoration = {
50+
const restDecoration: monaco.editor.IModelDeltaDecoration | undefined = lastLineMatch ? {
5151
range: {
5252
startLineNumber: firstLineMatch.range.startLineNumber + 1,
5353
endLineNumber: lastLineMatch.range.startLineNumber,
@@ -59,8 +59,8 @@ export default function addMainContractCodeDecoration(model: monaco.editor.IText
5959
className: '.main-contract-body',
6060
marginClassName: '.main-contract-body',
6161
},
62-
};
62+
} : undefined;
6363

6464
editor.updateOptions({ glyphMargin: true });
65-
model.deltaDecorations([], [ firstLineDecoration, restDecoration ]);
65+
model.deltaDecorations([], [ firstLineDecoration, restDecoration ].filter(Boolean));
6666
}

0 commit comments

Comments
 (0)