-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
open multiple files in one app instance if possible #451
base: master
Are you sure you want to change the base?
Conversation
src/mime_app.rs
Outdated
@@ -10,16 +10,20 @@ use std::{ | |||
cmp::Ordering, collections::HashMap, env, path::PathBuf, process, sync::Mutex, time::Instant, | |||
}; | |||
|
|||
pub fn exec_to_command(exec: &str, path_opt: Option<PathBuf>) -> Option<process::Command> { | |||
pub fn exec_to_command(exec: &str, path_opt: Vec<Option<PathBuf>>) -> Option<process::Command> { | |||
let args_vec: Vec<String> = shlex::split(exec)?; | |||
let mut args = args_vec.iter(); | |||
let mut command = process::Command::new(args.next()?); | |||
for arg in args { | |||
if arg.starts_with('%') { | |||
match arg.as_str() { | |||
"%f" | "%F" | "%u" | "%U" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a program provides %f or %u it means only a single path or URL. %F or %U can accept a list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, did not know. To be honest I was reading about it today, because testing something but I did not consider it here 😓 Should I split this match pattern and in this case provide only first argument from vector and full list in other case?
@@ -2165,6 +2165,51 @@ impl Application for App { | |||
} | |||
} | |||
} | |||
tab::Command::OpenMultipleFiles(items) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a fallback to the original open code if no default apps are found, which will always happen on OSes like macOS and Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, did not think about it. Of course I will make this change :)
I made some changes. Second, about arguments. Was not sure how to handle this case, so just passing first argument from vector. I don't know if it's correct tho. |
This will allow to open multiple files in one app instance. So for example, we opening 3x text files, so they will be opened in COSMIC Text (default app for specific mimetype) in 3 tabs, instead of 3 apps. Don't know if this is needed or implementation is fine but I'm sure to not broke anything 😅 If there will be one file selected, it will open just like before. Only handle for multiple files is featured. I tested this on multiple files for the same type:
From my testing, seems to work.