@@ -548,6 +548,113 @@ function getImplicitArgOffset(model: _Model): Offset {
548548 return model . offsetOf ( atom ) ;
549549}
550550
551+ /**
552+ * Check if the atom is part of a scientific notation pattern
553+ * Handles both: 5e-2 and 3.14×10^-2 formats
554+ */
555+ function isPartOfScientificNotation ( atom : Atom ) : boolean {
556+ // Pattern 1: 'e' notation (e.g., 5e-2, 3.14e+10)
557+ // Check if this is 'e' preceded by a digit
558+ if ( atom . type === 'mord' && atom . value === 'e' ) {
559+ const left = atom . leftSibling ;
560+ if ( left && left . isDigit ( ) ) return true ;
561+ }
562+
563+ // Check if this is '+' or '-' preceded by 'e' and that 'e' is preceded by a digit
564+ // Note: minus might be '-' (hyphen-minus) or '−' (minus sign U+2212)
565+ if (
566+ atom . type === 'mbin' &&
567+ ( atom . value === '+' || atom . value === '-' || atom . value === '−' )
568+ ) {
569+ const left = atom . leftSibling ;
570+ const right = atom . rightSibling ;
571+ if (
572+ left &&
573+ left . type === 'mord' &&
574+ left . value === 'e' &&
575+ right &&
576+ right . isDigit ( )
577+ ) {
578+ const leftLeft = left . leftSibling ;
579+ if ( leftLeft && leftLeft . isDigit ( ) ) return true ;
580+ }
581+ }
582+
583+ // Pattern 2: ×10^ notation (e.g., 3.14×10^-2, 5×10^3)
584+ // The structure is: digit(s) × 1 0 subsup
585+ // where the subsup has the exponent in its superscript branch
586+
587+ // Check if this is a subsup atom (the ^ part after 10)
588+ if ( atom . type === 'subsup' ) {
589+ // Check if left siblings are "0" and "1"
590+ const left1 = atom . leftSibling ; // should be "0"
591+ if ( left1 && left1 . isDigit ( ) && left1 . value === '0' ) {
592+ const left2 = left1 . leftSibling ; // should be "1"
593+ if ( left2 && left2 . isDigit ( ) && left2 . value === '1' ) {
594+ // Check if preceded by × (times)
595+ const left3 = left2 . leftSibling ;
596+ if ( left3 && left3 . type === 'mbin' && ( left3 . value === '×' || left3 . value === '\\times' ) ) {
597+ // Check if the times is preceded by a digit
598+ const left4 = left3 . leftSibling ;
599+ if ( left4 && left4 . isDigit ( ) ) return true ;
600+ }
601+ }
602+ }
603+ }
604+
605+ // Check if this is "0" that's part of "10^"
606+ if ( atom . isDigit ( ) && atom . value === '0' ) {
607+ const left = atom . leftSibling ; // should be "1"
608+ const right = atom . rightSibling ; // should be subsup
609+ if (
610+ left && left . isDigit ( ) && left . value === '1' &&
611+ right && right . type === 'subsup'
612+ ) {
613+ // Check if "1" is preceded by ×
614+ const left2 = left . leftSibling ;
615+ if ( left2 && left2 . type === 'mbin' && ( left2 . value === '×' || left2 . value === '\\times' ) ) {
616+ // Check if × is preceded by a digit
617+ const left3 = left2 . leftSibling ;
618+ if ( left3 && left3 . isDigit ( ) ) return true ;
619+ }
620+ }
621+ }
622+
623+ // Check if this is "1" that's part of "10^"
624+ if ( atom . isDigit ( ) && atom . value === '1' ) {
625+ const right1 = atom . rightSibling ; // should be "0"
626+ if ( right1 && right1 . isDigit ( ) && right1 . value === '0' ) {
627+ const right2 = right1 . rightSibling ; // should be subsup
628+ if ( right2 && right2 . type === 'subsup' ) {
629+ // Check if preceded by ×
630+ const left = atom . leftSibling ;
631+ if ( left && left . type === 'mbin' && ( left . value === '×' || left . value === '\\times' ) ) {
632+ // Check if × is preceded by a digit
633+ const left2 = left . leftSibling ;
634+ if ( left2 && left2 . isDigit ( ) ) return true ;
635+ }
636+ }
637+ }
638+ }
639+
640+ // Check if this is × (times) in the pattern digit × 10^exponent
641+ if ( atom . type === 'mbin' && ( atom . value === '×' || atom . value === '\\times' ) ) {
642+ const left = atom . leftSibling ;
643+ const right1 = atom . rightSibling ; // should be "1"
644+ if ( left && left . isDigit ( ) && right1 && right1 . isDigit ( ) && right1 . value === '1' ) {
645+ const right2 = right1 . rightSibling ; // should be "0"
646+ if ( right2 && right2 . isDigit ( ) && right2 . value === '0' ) {
647+ const right3 = right2 . rightSibling ; // should be subsup
648+ if ( right3 && right3 . type === 'subsup' ) {
649+ return true ;
650+ }
651+ }
652+ }
653+ }
654+
655+ return false ;
656+ }
657+
551658/**
552659 *
553660 * Predicate returns true if the atom should be considered an implicit argument.
@@ -559,6 +666,10 @@ function getImplicitArgOffset(model: _Model): Offset {
559666function isImplicitArg ( atom : Atom ) : boolean {
560667 // A digit, or a decimal point
561668 if ( atom . isDigit ( ) ) return true ;
669+
670+ // Check for scientific notation patterns
671+ if ( isPartOfScientificNotation ( atom ) ) return true ;
672+
562673 if (
563674 atom . type &&
564675 / ^ ( m o r d | s u r d | s u b s u p | l e f t r i g h t | m o p | m c l o s e ) $ / . test ( atom . type )
0 commit comments