Skip to content

Commit fcb349c

Browse files
Nakshatra SharmaNakshatra Sharma
authored andcommitted
Fix Verilog initialization crash on first launch by adding null checks for CodeMirror editor.
1 parent 5fb1a1b commit fcb349c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/simulator/src/Verilog2CV.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export async function createVerilogCircuit() {
4747
)
4848

4949
if (returned) {
50+
if (!editor) {
51+
setupCodeMirrorEnvironment()
52+
}
53+
5054
verilogModeSet(true)
5155

5256
try {
@@ -102,7 +106,9 @@ function clearVerilogOutput() {
102106
}
103107

104108
export function resetVerilogCode() {
105-
editor.setValue(globalScope.verilogMetadata.code)
109+
if (editor) {
110+
editor.setValue(globalScope.verilogMetadata.code)
111+
}
106112
}
107113

108114
export function hasVerilogCodeChanges() {
@@ -311,6 +317,7 @@ export default function generateVerilogCircuit(
311317

312318
export function setupCodeMirrorEnvironment() {
313319
var myTextarea = document.getElementById('codeTextArea')
320+
if (!myTextarea) return
314321

315322
CodeMirror.commands.autocomplete = function (cm) {
316323
cm.showHint({ hint: CodeMirror.hint.anyword })

0 commit comments

Comments
 (0)