Repository: helix-editor/helix (language: rust)

Issue:
Read (:r) command does not properly expand ~ to mean "user's home directory"
### Summary

If you try to read in a file like this:

```
:r ~/some/file
```

This will result in the error:

```
path is not a file: "~/some/file"
```

Even though (a) the file exists, and (b) the path autocompletes successfully.

### Reproduction Steps

(I think the summary covers this)

### Helix log

(nothing is logged in helix.log in reponse to this failure)

### Platform

Linux

### Terminal Emulator

ptyxis

### Installation Method

source

### Helix Version

24.07-328-ge14c346e


Discussion / hints:
The issue is in [this line](https://github.com/helix-editor/helix/blob/master/helix-term/src/commands/typed.rs#L2510). The `PathBuf::from` function (and other methods in the std::path module) don't automatically expand the tilde to the user's home directory since it's a shell feature, and not a universal thing. The common solution is to manually expand the tilde, if present.

I'd be down to do it tomorrow, I've already got a dirty thing working. I haven't yet contributed so not sure of the protocol of it all.

Fix patch:
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 49864abb683e..4c5d568aad6d 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -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");
 
     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!(
         path.exists() && path.is_file(),
         "path is not a file: {:?}",


Test patch: