Fix: Improve rename functionality and error handling

Co-authored-by: ijamespine <ijamespine@me.com>
This commit is contained in:
Cursor Agent
2025-12-24 17:26:27 +00:00
parent 06f0406b82
commit ca9b8f3f73
4 changed files with 21 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
//! File rename action handler
use super::input::FileRenameInput;
use super::validation::{validate_filename, FilenameValidationError};
use super::validation::validate_filename;
use crate::{
context::CoreContext,
domain::addressing::SdPath,

View File

@@ -223,15 +223,15 @@ impl VolumeBackend for LocalBackend {
recursive
);
if recursive {
fs::create_dir_all(&full_path)
.await
.map_err(|e| VolumeError::Io(e))?;
} else {
fs::create_dir(&full_path)
.await
.map_err(|e| VolumeError::Io(e))?;
}
if recursive {
fs::create_dir_all(&full_path)
.await
.map_err(VolumeError::Io)?;
} else {
fs::create_dir(&full_path)
.await
.map_err(VolumeError::Io)?;
}
Ok(())
}

View File

@@ -5,7 +5,7 @@ import clsx from "clsx";
interface InlineNameEditProps {
file: File;
onSave: (newName: string) => void;
onSave: (newName: string) => Promise<void>;
onCancel: () => void;
className?: string;
}
@@ -55,13 +55,13 @@ export function InlineNameEdit({ file, onSave, onCancel, className }: InlineName
return;
}
setIsSaving(true);
try {
onSave(fullNewName);
} catch (error) {
setIsSaving(false);
// Keep in edit mode on error - let parent handle error display
}
setIsSaving(true);
try {
await onSave(fullNewName);
} catch (error) {
setIsSaving(false);
// Keep in edit mode on error - let parent handle error display
}
}, [value, isSaving, hasExtension, file.extension, file.name, onSave, onCancel]);
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {

View File

@@ -128,15 +128,15 @@ export function useExplorerKeyboard() {
{ enabled: clipboard.hasClipboard() && !!currentPath },
);
// Rename: Enter key triggers rename mode when single file selected
// Rename: Enter key triggers rename mode when single file selected (not directories)
useKeybind(
"explorer.renameFile",
() => {
if (selectedFiles.length === 1 && !isRenaming) {
if (selectedFiles.length === 1 && !isRenaming && selectedFiles[0].kind !== "Directory") {
startRename(selectedFiles[0].id);
}
},
{ enabled: selectedFiles.length === 1 && !isRenaming },
{ enabled: selectedFiles.length === 1 && !isRenaming && selectedFiles[0]?.kind !== "Directory" },
);
useEffect(() => {