-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Problem (one or two sentences)
When using Roo for complex requirement coding, occasionally the last line of the code editor appears with a line number.
Context (who is affected and when)
developers use roo to do coding task may has this issue.
the apply_diff example:
`<<<<<<< SEARCH
1473 | ContactRelaEnum.MS.name(), addressList, contactStatusMap, SensitiveType.ADDRESS, curSector);
1474 | }
1475 | }
1476 | List addressInfoList = new ArrayList<>(CollectionUtils.size(repairInfoList) > 10 ? 10
1477 | : CollectionUtils.size(repairInfoList) + CollectionUtils.size(homeAddressInfoList)
1478 | + CollectionUtils.size(idNoAddressInfoList) + CollectionUtils.size(workAddressInfoList)
1479 | + CollectionUtils.size(personIdentityInfoList));
=======
1473 | ContactRelaEnum.MS.name(), addressList, contactStatusMap, SensitiveType.ADDRESS, curSector);
1474 | }
1475 | }
1476 |
1477 | //
1478 | if (isAddressDisplayOptimizeEnabled()) {
1479 | homeAddressInfoList = filterAddressesByThreeYearRule(homeAddressInfoList);
1480 | personIdentityInfoList = filterAddressesByThreeYearRule(personIdentityInfoList);
1481 | idNoAddressInfoList = filterAddressesByThreeYearRule(idNoAddressInfoList);
1482 | workAddressInfoList = filterAddressesByThreeYearRule(workAddressInfoList);
1483 | }
1484 |
1485 | List addressInfoList = new ArrayList<>(CollectionUtils.size(repairInfoList) > 10 ? 10
1486 | : CollectionUtils.size(repairInfoList) + CollectionUtils.size(homeAddressInfoList)
1487 | + CollectionUtils.size(idNoAddressInfoList) + CollectionUtils.size(workAddressInfoList)
1488 | + CollectionUtils.size(personIdentityInfoList));REPLACE`
and after stripLineNumbers, the result is

we debug and found this regex in multi-search-replace.ts will remove the last \n in SEARCH and REPLACE
let matches = [ ...diffContent.matchAll( /(?:^|\n)(?<!\\)<<<<<<< SEARCH>?\s*\n((?:\:start_line:\s*(\d+)\s*\n))?((?:\:end_line:\s*(\d+)\s*\n))?((?<!\\)-------\s*\n)?([\s\S]*?)(?:\n)?(?:(?<=\n)(?<!\\)=======\s*\n)([\s\S]*?)(?:\n)?(?:(?<=\n)(?<!\\)>>>>>>> REPLACE)(?=\n|$)/g, ), ]
1488 | \t\t\t\t\t\t+ CollectionUtils.size(personIdentityInfoList));\r\n
becomes
1488 | \t\t\t\t\t\t+ CollectionUtils.size(personIdentityInfoList));\r
thus stripLineNumbers() cannot match the line number
Reproduction steps
- Windows, Roo 3.28.2, model is qwen3-coder-480b
- The input is a feature design document, but that doesn’t matter here
- After 20–30 LLM rounds, the accumulated multi-turn context exceeds 100K. This may cause the LLM to be unstable when using apply_diff. When Roo begins editing a Java file, there is a certain probability that the last line of the edit will appear with a line number.
Expected result
no line number
Actual result
it has line number at the last edited line
Variations tried (optional)
No response
App Version
3.28.2
API Provider (optional)
OpenAI Compatible
Model Used (optional)
qwen3-coder-480b
Roo Code Task Links (optional)
No response
Relevant logs or errors (optional)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status