@@ -11,7 +11,7 @@ export function findCursor<T extends { disabled?: boolean }>(
1111 const maxCursor = Math . max ( options . length - 1 , 0 ) ;
1212 const clampedCursor = newCursor < 0 ? maxCursor : newCursor > maxCursor ? 0 : newCursor ;
1313 const newOption = options [ clampedCursor ] ;
14- if ( newOption . disabled ) {
14+ if ( newOption ? .disabled ) {
1515 return findCursor ( clampedCursor , delta < 0 ? - 1 : 1 , options ) ;
1616 }
1717 return clampedCursor ;
@@ -37,20 +37,22 @@ export function findTextCursor(
3737
3838 cursorY = Math . max ( 0 , Math . min ( lines . length - 1 , cursorY + deltaY ) ) ;
3939
40- cursorX = Math . min ( cursorX , lines [ cursorY ] . length ) + deltaX ;
40+ // biome-ignore-start lint/style/noNonNullAssertion: cursorY/i are always kept within lines bounds
41+ cursorX = Math . min ( cursorX , lines [ cursorY ] ! . length ) + deltaX ;
4142 while ( cursorX < 0 && cursorY > 0 ) {
4243 cursorY -- ;
43- cursorX += lines [ cursorY ] . length + 1 ;
44+ cursorX += lines [ cursorY ] ! . length + 1 ;
4445 }
45- while ( cursorX > lines [ cursorY ] . length && cursorY < lines . length - 1 ) {
46- cursorX -= lines [ cursorY ] . length + 1 ;
46+ while ( cursorX > lines [ cursorY ] ! . length && cursorY < lines . length - 1 ) {
47+ cursorX -= lines [ cursorY ] ! . length + 1 ;
4748 cursorY ++ ;
4849 }
49- cursorX = Math . max ( 0 , Math . min ( lines [ cursorY ] . length , cursorX ) ) ;
50+ cursorX = Math . max ( 0 , Math . min ( lines [ cursorY ] ! . length , cursorX ) ) ;
5051
5152 let newCursor = 0 ;
5253 for ( let i = 0 ; i < cursorY ; i ++ ) {
53- newCursor += lines [ i ] . length + 1 ;
54+ newCursor += lines [ i ] ! . length + 1 ;
5455 }
56+ // biome-ignore-end lint/style/noNonNullAssertion: end of clamped cursor block
5557 return newCursor + cursorX ;
5658}
0 commit comments