mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: handle undefined content in WriteToFileTool handlePartial method
- Fix ENOENT error when creating new files in Code mode - Ensure diffViewProvider.open is called even when content is undefined in partial blocks - Update test to reflect correct behavior for file creation workflow - Fixes #9611
This commit is contained in:
parent
56c630ca92
commit
9fec1dafd4
2 changed files with 9 additions and 6 deletions
|
|
@ -330,11 +330,11 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
|
|||
const partialMessage = JSON.stringify(sharedMessageProps)
|
||||
await task.ask("tool", partialMessage, block.partial).catch(() => {})
|
||||
|
||||
if (newContent) {
|
||||
if (!task.diffViewProvider.isEditing) {
|
||||
await task.diffViewProvider.open(relPath)
|
||||
}
|
||||
if (!task.diffViewProvider.isEditing) {
|
||||
await task.diffViewProvider.open(relPath)
|
||||
}
|
||||
|
||||
if (newContent) {
|
||||
await task.diffViewProvider.update(
|
||||
everyLineHasLineNumbers(newContent) ? stripLineNumbers(newContent) : newContent,
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -354,10 +354,13 @@ describe("writeToFileTool", () => {
|
|||
expect(mockCline.diffViewProvider.open).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("returns early when content is undefined in partial block", async () => {
|
||||
it("opens file even when content is undefined in partial block", async () => {
|
||||
await executeWriteFileTool({ content: undefined }, { isPartial: true })
|
||||
|
||||
expect(mockCline.diffViewProvider.open).not.toHaveBeenCalled()
|
||||
// File should be opened to create it, even if content is not yet available
|
||||
expect(mockCline.diffViewProvider.open).toHaveBeenCalledWith(testFilePath)
|
||||
// But update should not be called since there's no content
|
||||
expect(mockCline.diffViewProvider.update).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it("streams content updates during partial execution", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue