don't create new file when base name matches current file

This commit is contained in:
Nate 2025-01-11 10:28:14 -08:00
parent 52857162d5
commit a3a6b7728a

View file

@ -94,11 +94,21 @@ export default function StepContainerPreToolbar(
return;
}
const fileUri = await inferResolvedUriFromRelativePath(
let fileUri = await inferResolvedUriFromRelativePath(
props.relativeFilepath,
ideMessenger.ide,
);
// Sometimes the model will decide to only output the base name
// in which case we shouldn't create a new file if it matches the current file
const exists = await ideMessenger.ide.fileExists(fileUri);
if (!exists) {
const activeFile = await ideMessenger.ide.getCurrentFile();
if (activeFile && activeFile.path.endsWith(props.relativeFilepath)) {
fileUri = activeFile.path;
}
}
ideMessenger.post("applyToFile", {
streamId: streamIdRef.current,
filepath: fileUri,