File tree Expand file tree Collapse file tree 4 files changed +28
-4
lines changed
Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ export function onBeforeInsertText(data: string): boolean {
5151 return true ;
5252 }
5353
54- //only allow newlines if the test has newlines
55- if ( data === "\n" && ! TestWords . hasNewline ) {
54+ //only allow newlines if the test has newlines or in zen mode
55+ if ( data === "\n" && ! TestWords . hasNewline && Config . mode !== "zen" ) {
5656 return true ;
5757 }
5858
Original file line number Diff line number Diff line change @@ -217,6 +217,7 @@ export async function onInsertText(options: OnInsertTextParams): Promise<void> {
217217 const result = await goToNextWord ( {
218218 correctInsert : correct ,
219219 isCompositionEnding : isCompositionEnding === true ,
220+ zenNewline : charIsNewline && Config . mode === "zen" ,
220221 } ) ;
221222 lastBurst = result . lastBurst ;
222223 increasedWordIndex = result . increasedWordIndex ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ type GoToNextWordParams = {
2121 correctInsert : boolean ;
2222 // this is used to tell test ui to update the word before moving to the next word (in case of a composition that ends with a space)
2323 isCompositionEnding : boolean ;
24+ zenNewline ?: boolean ;
2425} ;
2526
2627type GoToNextWordReturn = {
@@ -31,13 +32,18 @@ type GoToNextWordReturn = {
3132export async function goToNextWord ( {
3233 correctInsert,
3334 isCompositionEnding,
35+ zenNewline,
3436} : GoToNextWordParams ) : Promise < GoToNextWordReturn > {
3537 const ret = {
3638 increasedWordIndex : false ,
3739 lastBurst : 0 ,
3840 } ;
3941
40- TestUI . beforeTestWordChange ( "forward" , correctInsert , isCompositionEnding ) ;
42+ TestUI . beforeTestWordChange (
43+ "forward" ,
44+ correctInsert ,
45+ isCompositionEnding || zenNewline === true
46+ ) ;
4147
4248 if ( correctInsert ) {
4349 Replay . addReplayEvent ( "submitCorrectWord" ) ;
Original file line number Diff line number Diff line change @@ -1766,7 +1766,24 @@ export async function afterTestWordChange(
17661766 }
17671767 } else if ( direction === "back" ) {
17681768 if ( Config . mode === "zen" ) {
1769- getWordElement ( TestState . activeWordIndex + 1 ) ?. remove ( ) ;
1769+ const wordsChildren = [
1770+ ...( document . querySelector ( "#words" ) ?. children ?? [ ] ) ,
1771+ ] as HTMLElement [ ] ;
1772+
1773+ let deleteElements = false ;
1774+ for ( const child of wordsChildren ) {
1775+ if (
1776+ ! deleteElements &&
1777+ parseInt ( child . getAttribute ( "data-wordindex" ) ?? "-1" , 10 ) ===
1778+ TestState . activeWordIndex
1779+ ) {
1780+ deleteElements = true ;
1781+ continue ;
1782+ }
1783+ if ( deleteElements ) {
1784+ child . remove ( ) ;
1785+ }
1786+ }
17701787 }
17711788 }
17721789}
You can’t perform that action at this time.
0 commit comments