@@ -77,7 +77,7 @@ const Editor: React.FC<EditorProps> = ({
7777 } ) ;
7878 } else if ( key . return ) {
7979 setLines ( ( prev ) => {
80- const currentLine = prev [ cursor . row ] || "" ;
80+ const currentLine = prev [ cursor . row ] ?? "" ;
8181 const before = currentLine . slice ( 0 , cursor . col ) ;
8282 const after = currentLine . slice ( cursor . col ) ;
8383 const newLines = [ ...prev ] ;
@@ -89,7 +89,7 @@ const Editor: React.FC<EditorProps> = ({
8989 if ( cursor . col > 0 ) {
9090 // Simple backspace within line
9191 setLines ( ( prev ) => {
92- const line = prev [ cursor . row ] || "" ;
92+ const line = prev [ cursor . row ] ?? "" ;
9393 const newLine = line . slice ( 0 , cursor . col - 1 ) + line . slice ( cursor . col ) ;
9494 const newLines = [ ...prev ] ;
9595 newLines [ cursor . row ] = newLine ;
@@ -99,14 +99,14 @@ const Editor: React.FC<EditorProps> = ({
9999 } else if ( cursor . row > 0 ) {
100100 // Merge with previous line
101101 setLines ( ( prev ) => {
102- const currentLine = prev [ cursor . row ] || "" ;
103- const prevLine = prev [ cursor . row - 1 ] || "" ;
102+ const currentLine = prev [ cursor . row ] ?? "" ;
103+ const prevLine = prev [ cursor . row - 1 ] ?? "" ;
104104 const newLines = [ ...prev ] ;
105105 newLines . splice ( cursor . row - 1 , 2 , prevLine + currentLine ) ;
106106 return newLines ;
107107 } ) ;
108108 setCursor ( ( prev ) => ( {
109- col : ( lines [ prev . row - 1 ] || "" ) . length ,
109+ col : ( lines [ prev . row - 1 ] ?? "" ) . length ,
110110 row : prev . row - 1 ,
111111 } ) ) ;
112112 }
@@ -123,7 +123,7 @@ const Editor: React.FC<EditorProps> = ({
123123 . then ( ( completion ) => {
124124 if ( completion ) {
125125 setLines ( ( prev ) => {
126- const line = prev [ cursor . row ] || "" ;
126+ const line = prev [ cursor . row ] ?? "" ;
127127 const newLine = line . slice ( 0 , cursor . col ) + completion + line . slice ( cursor . col ) ;
128128 const newLines = [ ...prev ] ;
129129 newLines [ cursor . row ] = newLine ;
@@ -149,7 +149,7 @@ const Editor: React.FC<EditorProps> = ({
149149 . then ( ( completion ) => {
150150 if ( completion ) {
151151 setLines ( ( prev ) => {
152- const line = prev [ cursor . row ] || "" ;
152+ const line = prev [ cursor . row ] ?? "" ;
153153 const newLine = line . slice ( 0 , cursor . col ) + completion + line . slice ( cursor . col ) ;
154154 const newLines = [ ...prev ] ;
155155 newLines [ cursor . row ] = newLine ;
@@ -161,7 +161,7 @@ const Editor: React.FC<EditorProps> = ({
161161 } else {
162162 // Regular typing
163163 setLines ( ( prev ) => {
164- const line = prev [ cursor . row ] || "" ;
164+ const line = prev [ cursor . row ] ?? "" ;
165165 const newLine = line . slice ( 0 , cursor . col ) + input + line . slice ( cursor . col ) ;
166166 const newLines = [ ...prev ] ;
167167 newLines [ cursor . row ] = newLine ;
@@ -205,7 +205,7 @@ const Editor: React.FC<EditorProps> = ({
205205 < Text >
206206 { line . slice ( 0 , cursor . col ) }
207207 < Text inverse color = "cyan" >
208- { line [ cursor . col ] || " " }
208+ { line [ cursor . col ] ?? " " }
209209 </ Text >
210210 { line . slice ( cursor . col + 1 ) }
211211 </ Text >
0 commit comments