on master help sign in
Changed startup behaviour to only open a single view when multiple files are specified on the commandline.
9fcbbfaCor
helix-term/src/application.rs+4−1
@@ -83,15 +83,18 @@ impl Application {
83 editor.new_file(Action::VerticalSplit);
83 editor.new_file(Action::VerticalSplit);
84 compositor.push(Box::new(ui::file_picker(first.clone())));
84 compositor.push(Box::new(ui::file_picker(first.clone())));
85 } else {
85 } else {
86+ let nr_of_files = args.files.len();
87+ editor.open(first.to_path_buf(), Action::VerticalSplit)?;
86 for file in args.files {
88 for file in args.files {
87 if file.is_dir() {
89 if file.is_dir() {
88 return Err(anyhow::anyhow!(
90 return Err(anyhow::anyhow!(
89 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
91 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
90 ));
92 ));
91 } else {
93 } else {
92− editor.open(file, Action::VerticalSplit)?;
94+ editor.open(file.to_path_buf(), Action::Load)?;
93 }
95 }
94 }
96 }
97+ editor.set_status(format!("Loaded {} files.", nr_of_files));
95 }
98 }
96 } else {
99 } else {
97 editor.new_file(Action::VerticalSplit);
100 editor.new_file(Action::VerticalSplit);
helix-view/src/editor.rs+4
@@ -39,6 +39,7 @@ pub struct Editor {
39
39
40#[derive(Debug, Copy, Clone)]
40#[derive(Debug, Copy, Clone)]
41pub enum Action {
41pub enum Action {
42+ Load,
42 Replace,
43 Replace,
43 HorizontalSplit,
44 HorizontalSplit,
44 VerticalSplit,
45 VerticalSplit,
@@ -151,6 +152,9 @@ impl Editor {
151
152
152 return;
153 return;
153 }
154 }
155+ Action::Load => {
156+ return;
157+ }
154 Action::HorizontalSplit => {
158 Action::HorizontalSplit => {
155 let view = View::new(id);
159 let view = View::new(id);
156 let view_id = self.tree.split(view, Layout::Horizontal);
160 let view_id = self.tree.split(view, Layout::Horizontal);