From 0f2ce303c5cac34ba88469d3ee13d44967f3e903 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 11 Jan 2025 20:38:29 -0500 Subject: [PATCH] Add directory name to `:cd` errors For example `:cd README.md` would say "Not a directory" but would not print the directory name. Now the error message includes some context about the operation and requested directory. --- helix-term/src/commands/typed.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 078bb800..4a2546d7 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -1105,7 +1105,12 @@ fn change_current_directory( None => Cow::Owned(home_dir()?), }; - cx.editor.set_cwd(&dir)?; + cx.editor.set_cwd(&dir).map_err(|err| { + anyhow!( + "Could not change working directory to '{}': {err}", + dir.display() + ) + })?; cx.editor.set_status(format!( "Current working directory is now {}",