feat: enhance file history range tracking with comprehensive overlap handling #6053
+1,384
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
This PR significantly improves the file history range tracking system to handle complex overlapping scenarios that were previously causing issues with redundant file reads and incorrect range calculations.
Implementation
Enhanced Range Detection:
computeModifiedRanges()
function for precise line-by-line change detectionadjustHistoricalRanges()
for proper range adjustment after content modificationsgetChangedLineRanges()
for comprehensive diff analysisImproved
calculateWriteRanges()
Logic:Comprehensive Test Coverage:
How to Test
Run the comprehensive test suite:
Test various file modification scenarios:
Benefits
Fixes #5871 #1374
Important
Enhances file history range tracking with precise overlap handling and updates tools to utilize these improvements.
computeModifiedRanges()
,adjustHistoricalRanges()
, andgetChangedLineRanges()
infileHistoryUtils.ts
for precise range detection and adjustment.calculateWriteRanges()
to compare original vs modified content, preserving valid ranges and handling complex scenarios.writeToFileTool
,insertContentTool
, andreadFileTool
to use enhanced range tracking.fileHistoryUtils.spec.ts
for partial overlaps, complete coverage, edge cases, and complex scenarios.FileLineRange
andFileMetadata
interfaces toapiMessages.ts
.Task.ts
to track file modification times and manage pending file metadata.This description was created by
for 79fcc89. You can customize this summary. It will automatically update as commits are pushed.