don't create new file when base name matches current file
This commit is contained in:
parent
52857162d5
commit
a3a6b7728a
1 changed files with 11 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue