File tree Expand file tree Collapse file tree
src/agents/sessions/tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,9 +217,12 @@ describe("read tool", () => {
217217 expect ( textContent ( result ) ) . toBe ( "File contains no readable text (3 bytes)." ) ;
218218 } ) ;
219219
220- it ( "describes newline-only files instead of returning blank content" , async ( ) => {
220+ it . each ( [
221+ [ "LF" , "\n" ] ,
222+ [ "CRLF" , "\r\n" ] ,
223+ ] ) ( "describes %s-only files instead of returning blank content" , async ( _label , contents ) => {
221224 const tempDir = tempDirs . make ( "openclaw-read-blank-line-" ) ;
222- await fs . writeFile ( path . join ( tempDir , "blank.txt" ) , "\n" ) ;
225+ await fs . writeFile ( path . join ( tempDir , "blank.txt" ) , contents ) ;
223226 const tool = createReadToolDefinition ( tempDir ) ;
224227
225228 const result = await tool . execute (
Original file line number Diff line number Diff line change @@ -534,9 +534,9 @@ export function createReadToolDefinition(
534534 } else {
535535 const decodedText =
536536 ops . decodeText ?.( { buffer, absolutePath } ) ?? buffer . toString ( "utf8" ) ;
537- const textContent = decodedText . startsWith ( "\uFEFF" )
538- ? decodedText . slice ( 1 )
539- : decodedText ;
537+ const textContent = (
538+ decodedText . startsWith ( "\uFEFF" ) ? decodedText . slice ( 1 ) : decodedText
539+ ) . replaceAll ( "\r\n" , "\n" ) ;
540540 const allLines = textContent . split ( "\n" ) ;
541541 if ( allLines . at ( - 1 ) === "" ) {
542542 allLines . pop ( ) ;
You can’t perform that action at this time.
0 commit comments