Expand tildes in :read command (#12271)

This commit is contained in:
Aaalibaba 2024-12-16 18:10:35 +01:00 committed by GitHub
parent 99fdbce566
commit 3b36cf1a15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2507,7 +2507,8 @@ fn read(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
ensure!(args.len() == 1, "only the file name is expected"); ensure!(args.len() == 1, "only the file name is expected");
let filename = args.first().unwrap(); let filename = args.first().unwrap();
let path = PathBuf::from(filename.to_string()); let path = helix_stdx::path::expand_tilde(PathBuf::from(filename.to_string()));
ensure!( ensure!(
path.exists() && path.is_file(), path.exists() && path.is_file(),
"path is not a file: {:?}", "path is not a file: {:?}",