on master help sign in
Changed startup behaviour to only open a single view when multiple files are specified on the commandline.

Changed the behaviour; the first argument on the commandline is the file on display

commit9fcbbfa46762484fc132383d9c2855ce37f60d6f authorCor <prive@corpeters.nl> dateWed 14 Jul 2021, 21:29 (5 years ago) parent000b7b7
2 files changed+8−1
helix-term/src/application.rs+4−1 helix-view/src/editor.rs+4
helix-term/src/application.rs+4−1
@@ -83,15 +83,18 @@ impl Application {
8383 editor.new_file(Action::VerticalSplit);
8484 compositor.push(Box::new(ui::file_picker(first.clone())));
8585 } else {
86+ let nr_of_files = args.files.len();
87+ editor.open(first.to_path_buf(), Action::VerticalSplit)?;
8688 for file in args.files {
8789 if file.is_dir() {
8890 return Err(anyhow::anyhow!(
8991 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
9092 ));
9193 } else {
92− editor.open(file, Action::VerticalSplit)?;
94+ editor.open(file.to_path_buf(), Action::Load)?;
9395 }
9496 }
97+ editor.set_status(format!("Loaded {} files.", nr_of_files));
9598 }
9699 } else {
97100 editor.new_file(Action::VerticalSplit);
helix-view/src/editor.rs+4
@@ -39,6 +39,7 @@ pub struct Editor {
3939
4040#[derive(Debug, Copy, Clone)]
4141pub enum Action {
42+ Load,
4243 Replace,
4344 HorizontalSplit,
4445 VerticalSplit,
@@ -151,6 +152,9 @@ impl Editor {
151152
152153 return;
153154 }
155+ Action::Load => {
156+ return;
157+ }
154158 Action::HorizontalSplit => {
155159 let view = View::new(id);
156160 let view_id = self.tree.split(view, Layout::Horizontal);