Skip to content

Commit 5178f24

Browse files
committed
Fix a crash when EditorView.composing is accessed during initialization
FIX: Fix a crash when `EditorView.composing` or `.compositionStarted` are accessed during view initialization. Closes codemirror/dev#1558
1 parent 04ef921 commit 5178f24

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/editorview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ export class EditorView {
109109
/// Indicates whether the user is currently composing text via
110110
/// [IME](https://en.wikipedia.org/wiki/Input_method), and at least
111111
/// one change has been made in the current composition.
112-
get composing() { return this.inputState.composing > 0 }
112+
get composing() { return !!this.inputState && this.inputState.composing > 0 }
113113

114114
/// Indicates whether the user is currently in composing state. Note
115115
/// that on some platforms, like Android, this will be the case a
116116
/// lot, since just putting the cursor on a word starts a
117117
/// composition there.
118-
get compositionStarted() { return this.inputState.composing >= 0 }
118+
get compositionStarted() { return !!this.inputState && this.inputState.composing >= 0 }
119119

120120
private dispatchTransactions: (trs: readonly Transaction[], view: EditorView) => void
121121

0 commit comments

Comments
 (0)