Fix file selection being reset when clicking entry file in tree
The useEffect that syncs selectedFile was resetting to an existing file whenever the selected path wasn't in the bundle's on-disk file list. This prevented selecting the entry file (e.g. AGENTS.md) when it didn't yet exist on disk, even though it was visible in the file tree. Allow selecting the currentEntryFile even when it has no on-disk file. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1636,7 +1636,7 @@ function PromptsTab({
|
||||
if (selectedFile !== bundle.entryFile) setSelectedFile(bundle.entryFile);
|
||||
return;
|
||||
}
|
||||
if (!availablePaths.includes(selectedFile)) {
|
||||
if (!availablePaths.includes(selectedFile) && selectedFile !== currentEntryFile) {
|
||||
setSelectedFile(availablePaths.includes(bundle.entryFile) ? bundle.entryFile : availablePaths[0]!);
|
||||
}
|
||||
}, [bundle, bundleMatchesDraft, currentEntryFile, selectedFile]);
|
||||
|
||||
Reference in New Issue
Block a user