mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
bug: Fix modify edit (#1078)
This commit is contained in:
@@ -467,10 +467,12 @@ Expectation for required parameters:
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
createUpdatedParams: (
|
createUpdatedParams: (
|
||||||
|
oldContent: string,
|
||||||
modifiedProposedContent: string,
|
modifiedProposedContent: string,
|
||||||
originalParams: EditToolParams,
|
originalParams: EditToolParams,
|
||||||
): EditToolParams => ({
|
): EditToolParams => ({
|
||||||
...originalParams,
|
...originalParams,
|
||||||
|
old_string: oldContent,
|
||||||
new_string: modifiedProposedContent,
|
new_string: modifiedProposedContent,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -74,9 +74,10 @@ describe('modifyWithEditor', () => {
|
|||||||
getProposedContent: vi.fn().mockResolvedValue(proposedContent),
|
getProposedContent: vi.fn().mockResolvedValue(proposedContent),
|
||||||
createUpdatedParams: vi
|
createUpdatedParams: vi
|
||||||
.fn()
|
.fn()
|
||||||
.mockImplementation((modifiedContent, originalParams) => ({
|
.mockImplementation((oldContent, modifiedContent, originalParams) => ({
|
||||||
...originalParams,
|
...originalParams,
|
||||||
modifiedContent,
|
modifiedContent,
|
||||||
|
oldContent,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,6 +154,7 @@ describe('modifyWithEditor', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(mockModifyContext.createUpdatedParams).toHaveBeenCalledWith(
|
expect(mockModifyContext.createUpdatedParams).toHaveBeenCalledWith(
|
||||||
|
currentContent,
|
||||||
modifiedContent,
|
modifiedContent,
|
||||||
mockParams,
|
mockParams,
|
||||||
);
|
);
|
||||||
@@ -183,6 +185,7 @@ describe('modifyWithEditor', () => {
|
|||||||
updatedParams: {
|
updatedParams: {
|
||||||
...mockParams,
|
...mockParams,
|
||||||
modifiedContent,
|
modifiedContent,
|
||||||
|
oldContent: currentContent,
|
||||||
},
|
},
|
||||||
updatedDiff: 'mock diff content',
|
updatedDiff: 'mock diff content',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface ModifyContext<ToolParams> {
|
|||||||
getProposedContent: (params: ToolParams) => Promise<string>;
|
getProposedContent: (params: ToolParams) => Promise<string>;
|
||||||
|
|
||||||
createUpdatedParams: (
|
createUpdatedParams: (
|
||||||
|
oldContent: string,
|
||||||
modifiedProposedContent: string,
|
modifiedProposedContent: string,
|
||||||
originalParams: ToolParams,
|
originalParams: ToolParams,
|
||||||
) => ToolParams;
|
) => ToolParams;
|
||||||
@@ -98,6 +99,7 @@ function getUpdatedParams<ToolParams>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updatedParams = modifyContext.createUpdatedParams(
|
const updatedParams = modifyContext.createUpdatedParams(
|
||||||
|
oldContent,
|
||||||
newContent,
|
newContent,
|
||||||
originalParams,
|
originalParams,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ export class WriteFileTool
|
|||||||
return correctedContentResult.correctedContent;
|
return correctedContentResult.correctedContent;
|
||||||
},
|
},
|
||||||
createUpdatedParams: (
|
createUpdatedParams: (
|
||||||
|
_oldContent: string,
|
||||||
modifiedProposedContent: string,
|
modifiedProposedContent: string,
|
||||||
originalParams: WriteFileToolParams,
|
originalParams: WriteFileToolParams,
|
||||||
) => ({
|
) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user