fix: improve error message when path has no file name

pull/12923/head
Jonas Köhnen 2025-02-28 19:14:36 +01:00
parent 5e5766a123
commit 8414e01906
No known key found for this signature in database
1 changed files with 3 additions and 3 deletions

View File

@ -2399,9 +2399,9 @@ fn move_buffer(cx: &mut compositor::Context, args: Args, event: PromptEvent) ->
let is_dir = new_path.is_dir(); let is_dir = new_path.is_dir();
let mut do_move = |old_path: PathBuf, editor: &mut Editor| { let mut do_move = |old_path: PathBuf, editor: &mut Editor| {
let file_name = old_path let Some(file_name) = old_path.file_name() else {
.file_name() bail!("Cannot move this path: {}", old_path.to_string_lossy());
.context("Cannot move file: source is root directory")?; };
// Allow moving files into directories without repeating the file name in the new path. // Allow moving files into directories without repeating the file name in the new path.
if is_dir { if is_dir {
new_path.push(file_name); new_path.push(file_name);