Skip to content

Commit

Permalink
Contract source code: the code for the empty contract is not displaye… (
Browse files Browse the repository at this point in the history
#2569)

Contract source code: the code for the empty contract is not displayed because of a JS crash

Fixes #2568
  • Loading branch information
tom2drum authored Feb 11, 2025
1 parent a135c4d commit b88ebe4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/shared/monaco/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const CodeEditor = ({ data, remappings, libraries, language, mainFile, contractN
}), [ editorWidth, themeColors, borderRadius ]);

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

if (data.length === 1) {
Expand Down
6 changes: 3 additions & 3 deletions ui/shared/monaco/utils/addMainContractCodeDecoration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));
}

0 comments on commit b88ebe4

Please sign in to comment.