From 56cec2b83713076b9c27751ca5c0c5e07943b6a8 Mon Sep 17 00:00:00 2001 From: Arno Gourdol Date: Tue, 23 May 2023 07:55:22 -0700 Subject: [PATCH] fix: fixed #1981 --- src/editor-mathfield/keyboard-input.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/editor-mathfield/keyboard-input.ts b/src/editor-mathfield/keyboard-input.ts index cb8e2a9e9..33b139efc 100644 --- a/src/editor-mathfield/keyboard-input.ts +++ b/src/editor-mathfield/keyboard-input.ts @@ -652,7 +652,12 @@ function insertMathModeChar( if (mathfield.adoptStyle !== 'none') { // If adding an alphabetic character, and the neighboring atom is an // alphanumeric character, use the same variant/variantStyle (\mathit, \mathrm...) - const sibling = mathfield.adoptStyle === 'left' ? atom : atom.rightSibling; + const sibling = + mathfield.adoptStyle === 'left' + ? atom + : atom.parent + ? atom.rightSibling + : null; if ( sibling?.type === 'mord' && /[a-zA-Z0-9]/.test(sibling.value) &&