Set the selection point of the first file correctly (#3073)

imgbot
Narazaki Shuji 2 years ago committed by GitHub
parent e8214fb1e6
commit 55b45ec4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -151,10 +151,7 @@ impl Application {
compositor.push(Box::new(overlayed(picker))); compositor.push(Box::new(overlayed(picker)));
} else { } else {
let nr_of_files = args.files.len(); let nr_of_files = args.files.len();
editor.open(first, Action::VerticalSplit)?; for (i, (file, pos)) in args.files.into_iter().enumerate() {
// Because the line above already opens the first file, we can
// simply skip opening it a second time by using .skip(1) here.
for (file, pos) in args.files.into_iter().skip(1) {
if file.is_dir() { if file.is_dir() {
return Err(anyhow::anyhow!( return Err(anyhow::anyhow!(
"expected a path to file, found a directory. (to open a directory pass it as first argument)" "expected a path to file, found a directory. (to open a directory pass it as first argument)"
@ -166,6 +163,7 @@ impl Application {
// option. If neither of those two arguments are passed // option. If neither of those two arguments are passed
// in, just load the files normally. // in, just load the files normally.
let action = match args.split { let action = match args.split {
_ if i == 0 => Action::VerticalSplit,
Some(Layout::Vertical) => Action::VerticalSplit, Some(Layout::Vertical) => Action::VerticalSplit,
Some(Layout::Horizontal) => Action::HorizontalSplit, Some(Layout::Horizontal) => Action::HorizontalSplit,
None => Action::Load, None => Action::Load,

Loading…
Cancel
Save