Commit 9fe600c632

9fe600c63281130d547f1012adc840b6da298f86

parent: 7d66421863

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-19 00:24 UTC
committer: <noreply@github.com>

Update `:open` and `:download` to also expand `~` (#716)

Layout: unified · split

src/base.rs +2 −2
@@ -99,7 +99,7 @@ pub enum MessageAction {
9999 ///
100100 /// The second argument controls whether to overwrite any already existing file at the
101101 /// destination path, or to open the attachment after downloading.
102 Download(Option<String>, DownloadFlags),
102 Download(Option<PathBuf>, DownloadFlags),
103103
104104 /// Edit a sent message.
105105 Edit,
@@ -525,7 +525,7 @@ pub enum SendAction {
525525 ///
526526 /// The second argument indicates whether to use the messagebar as a caption, don't use it or
527527 /// ask the user.
528 Upload(String, Option<bool>),
528 Upload(PathBuf, Option<bool>),
529529
530530 /// Upload the image data.
531531 ///
src/commands.rs +4 −7
@@ -965,17 +965,14 @@ fn iamb_space(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
965965}
966966
967967fn iamb_upload(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
968 let mut args = desc.arg.strings()?;
968 let mut args = desc.arg.paths()?;
969969
970970 if args.len() != 1 {
971971 return Result::Err(CommandError::InvalidArgument);
972972 }
973973
974974 let path = args.remove(0);
975 let expanded_path =
976 shellexpand::full(&path).map_err(|e| CommandError::ParseFailed(e.to_string()))?;
977
978 let sact = SendAction::Upload(expanded_path.into_owned(), None);
975 let sact = SendAction::Upload(path, None);
979976 let iact = IambAction::from(sact);
980977 let step = CommandStep::Continue(iact.into(), ctx.context.clone());
981978
@@ -983,7 +980,7 @@ fn iamb_upload(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
983980}
984981
985982fn iamb_download(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
986 let mut args = desc.arg.strings()?;
983 let mut args = desc.arg.paths()?;
987984
988985 if args.len() > 1 {
989986 return Result::Err(CommandError::InvalidArgument);
@@ -1001,7 +998,7 @@ fn iamb_download(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult
1001998}
1002999
10031000fn iamb_open(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult {
1004 let mut args = desc.arg.strings()?;
1001 let mut args = desc.arg.paths()?;
10051002
10061003 if args.len() > 1 {
10071004 return Result::Err(CommandError::InvalidArgument);
src/windows/room/chat.rs +4 −5
@@ -181,7 +181,7 @@ impl ChatState {
181181
182182 let media = client.media();
183183 let mut filename = match (filename, &settings.dirs.downloads) {
184 (Some(f), _) => PathBuf::from(f),
184 (Some(f), _) => f,
185185 (None, Some(downloads)) => downloads.clone(),
186186 (None, None) => return Err(IambError::NoDownloadDir.into()),
187187 };
@@ -684,11 +684,10 @@ impl ChatState {
684684 return Err(UIError::NeedConfirm(prompt));
685685 }
686686
687 let path = Path::new(file.as_str());
688 let mime = mime_guess::from_path(path).first_or(mime::APPLICATION_OCTET_STREAM);
687 let mime = mime_guess::from_path(&file).first_or(mime::APPLICATION_OCTET_STREAM);
689688
690 let bytes = fs::read(path)?;
691 let name = path
689 let bytes = fs::read(&file)?;
690 let name = file
692691 .file_name()
693692 .map(OsStr::to_string_lossy)
694693 .unwrap_or_else(|| Cow::from("Attachment"));