@@ -19,10 +19,7 @@ import { useCheckForUserNavigator } from "@/lib/user-system";
1919import  {  catchError  }  from  "@/lib/utils" ; 
2020import  type  {  Snippet  }  from  "@prisma/client" ; 
2121import  type  {  User  }  from  "next-auth" ; 
22- import  type  {  ChartTimeStamp  }  from  "./types" ; 
23- import  type  {  ReplayTimeStamp  }  from  "./types" ; 
24- import  {  catchError  }  from  "@/lib/utils" ; 
25- import  {  useCheckForUserNavigator  }  from  "@/lib/user-system" ; 
22+ import  type  {  ChartTimeStamp ,  ReplayTimeStamp  }  from  "./types" ; 
2623import  {  useEffectOnce  }  from  "react-use" ; 
2724
2825type  RacePracticeProps  =  { 
@@ -44,22 +41,18 @@ export default function RacePractice({ user, snippet }: RacePracticeProps) {
4441 const  router  =  useRouter ( ) ; 
4542 const  isRaceFinished  =  input  ===  code ; 
4643
47- < < << << <  HEAD 
48-  const  isUserOnAdroid  =  useCheckForUserNavigator ( "android" ) ; 
44+  const  isUserOnAndroid  =  useCheckForUserNavigator ( "android" ) ; 
4945 //for auto scroll 
5046 const  preElement  =  useRef < HTMLPreElement  |  null > ( null ) ; 
5147 const  scrollUpperLimit  =  7 ; 
5248 const  scrollLowerLimit  =  7  -  1 ;  //1 is deducted because when scrolling backwards, we count from the left side 
53-  const  spanElementWidth  =  10.4 ; 
54- = === === 
55-  const  isUserOnAndroid  =  useCheckForUserNavigator ( "android" ) ; 
56- 
57- > >>> >>>  1 f8ec0865da4c364680b7fed3dfc32e978617bc6 
49+  const  spanElementWidth  =  10.4 ;  //the span element will always have this width 
5850 useEffect ( ( )  =>  { 
5951 localStorage . removeItem ( "chartTimeStamp" ) ; 
6052 if  ( ! inputElement . current )  return ; 
6153 inputElement . current . focus ( ) ; 
6254 } ) ; 
55+  
6356 useEffectOnce ( ( )  =>  { 
6457 if  ( preElement . current )  { 
6558 setWindowEnd ( 
@@ -121,7 +114,7 @@ export default function RacePractice({ user, snippet }: RacePracticeProps) {
121114 } 
122115 } 
123116 } ) ; 
124-   
117+ 
125118 // eslint-disable-next-line @typescript-eslint/no-explicit-any 
126119 function  handleInputEvent ( e : any  /** React.FormEvent<HTMLInputElement>*/ )  { 
127120 if  ( ! isUserOnAndroid )  return ; 
@@ -386,8 +379,15 @@ export default function RacePractice({ user, snippet }: RacePracticeProps) {
386379 setTotalErrors ( 0 ) ; 
387380 setReplayTimeStamp ( [ ] ) ; 
388381 setChartTimeStamp ( [ ] ) ; 
382+  setWindowEnd ( 
383+  Math . floor ( 
384+  // eslint-disable-next-line @typescript-eslint/no-explicit-any 
385+  ( preElement . current ?. getBoundingClientRect ( ) . width  as  any )  / 
386+  spanElementWidth 
387+  ) 
388+  ) ; 
389389 } 
390- 
390+   //function to handle scroll to the right 
391391 function  handleScrollPositive ( updatedInput : string )  { 
392392 const  lineNumber  =  input . split ( "\n" ) . length ; 
393393 const  totalCharactersInput  =  Number ( 
@@ -399,6 +399,7 @@ export default function RacePractice({ user, snippet }: RacePracticeProps) {
399399 setScrollPosition ( ( prev )  =>  prev  +  spanElementWidth ) ; 
400400 } 
401401 } 
402+  //function to handle scroll to the left when backspaced 
402403 function  handleScrollNegative ( updatedInput : string )  { 
403404 const  lineNumber  =  input . split ( "\n" ) . length ; 
404405 const  totalCharactersInput  =  Number ( 
0 commit comments