@@ -186,7 +186,6 @@ describe("read_file tool with maxReadFileLine setting", () => {
186186
187187 return toolResult
188188 }
189-
190189 describe ( "when maxReadFileLine is negative" , ( ) => {
191190 it ( "should read the entire file using extractTextFromFile" , async ( ) => {
192191 // Setup - use default mockInputContent
@@ -201,6 +200,43 @@ describe("read_file tool with maxReadFileLine setting", () => {
201200 expect ( mockedParseSourceCodeDefinitionsForFile ) . not . toHaveBeenCalled ( )
202201 expect ( result ) . toBe ( expectedFullFileXml )
203202 } )
203+
204+ it ( "should ignore range parameters and read entire file when maxReadFileLine is -1" , async ( ) => {
205+ // Setup - use default mockInputContent
206+ mockInputContent = fileContent
207+
208+ // Execute with range parameters
209+ const result = await executeReadFileTool (
210+ {
211+ start_line : "2" ,
212+ end_line : "4" ,
213+ } ,
214+ { maxReadFileLine : - 1 } ,
215+ )
216+
217+ // Verify that extractTextFromFile is still used (not readLines)
218+ expect ( mockedExtractTextFromFile ) . toHaveBeenCalledWith ( absoluteFilePath )
219+ expect ( mockedReadLines ) . not . toHaveBeenCalled ( )
220+ expect ( mockedParseSourceCodeDefinitionsForFile ) . not . toHaveBeenCalled ( )
221+ expect ( result ) . toBe ( expectedFullFileXml )
222+ } )
223+
224+ it ( "should not show line snippet in approval message when maxReadFileLine is -1" , async ( ) => {
225+ // This test verifies the line snippet behavior for the approval message
226+ // Setup - use default mockInputContent
227+ mockInputContent = fileContent
228+
229+ // Execute - we'll reuse executeReadFileTool to run the tool
230+ await executeReadFileTool ( { } , { maxReadFileLine : - 1 } )
231+
232+ // Verify the empty line snippet for full read was passed to the approval message
233+ // Look at the parameters passed to the 'ask' method in the approval message
234+ const askCall = mockCline . ask . mock . calls [ 0 ]
235+ const completeMessage = JSON . parse ( askCall [ 1 ] )
236+
237+ // Verify the reason (lineSnippet) is empty or undefined for full read
238+ expect ( completeMessage . reason ) . toBeFalsy ( )
239+ } )
204240 } )
205241
206242 describe ( "when maxReadFileLine is 0" , ( ) => {
0 commit comments