Lib.typeIntoEditor method
Lib › typeIntoEditor
Types text into a CodeMirrorEditor using **trusted** Electron keyboard input.Typing is pressing each character key in turn: this focuses the editor (caret to end) and presses every code point of
text via Lib.pressKey — the same trusted keyDown → char → keyUp a real user produces. Each keystroke is delivered to the window's DOM-focused element and flows through CodeMirror's real input pipeline, so the typed text reaches the document **only if the editor genuinely holds focus**. This makes "the user typed into the editor" a faithful end-to-end check, unlike dispatchEvent(new KeyboardEvent(...)) (untrusted — ignored by CodeMirror) or execCommand('insertText') (mutates the selection even when the editor is not focused, masking focus bugs as false positives).After injecting the keystrokes it polls until the document reflects the input, or a bounded timeout elapses (the expected outcome when the editor is read-only and rejects the input, or when focus was stolen).
Signature:
typeIntoEditor(this: void, params: TypeIntoEditorParams): Promise<void>Parameters:
| Parameter | Type | Description |
|---|---|---|
| this | void | |
| params | TypeIntoEditorParams | The editor to type into and the text to type. |
Returns: Promise<void> — A Promise that resolves once the keystrokes have settled.