Skip to content

Commit 4f08f6b

Browse files
committed
Fix: avoid referring to uninitialized variable.
1 parent 89a90b6 commit 4f08f6b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

client/src/CodeChatEditor.mts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ declare global {
133133
// -------
134134
//
135135
// True to enable additional debug logging.
136-
export const DEBUG_ENABLED = false;
136+
export const DEBUG_ENABLED = true;
137137

138138
// The ID of the autosave timer; when this timer expires, the document will be
139139
// autosaved.
@@ -219,7 +219,9 @@ const on_dom_content_loaded = (on_load_func: () => void) => {
219219
//
220220
// True if this is a CodeChat Editor document (not a source file).
221221
const is_doc_only = () => {
222-
return current_metadata["mode"] === "markdown";
222+
// This might be called by the framework before a document is loaded.
223+
// So, make sure `current_metadata` exists first.
224+
return current_metadata !== undefined && current_metadata["mode"] === "markdown";
223225
};
224226

225227
// Wait for the DOM to load before opening the file.

0 commit comments

Comments
 (0)