@@ -25,7 +25,7 @@ use std::{
25 time::{Duration, Instant},
25 time::{Duration, Instant},
28−use anyhow::Error;
28+use anyhow::{Context, Error};
30use crossterm::{
30use crossterm::{
31 event::{DisableMouseCapture, EnableMouseCapture, Event},
31 event::{DisableMouseCapture, EnableMouseCapture, Event},
@@ -122,7 +122,7 @@ impl Application {
123 let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
123 let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
125− let mut compositor = Compositor::new()?;
125+ let mut compositor = Compositor::new().context("build compositor")?;
126 let config = Arc::new(ArcSwap::from_pointee(config));
126 let config = Arc::new(ArcSwap::from_pointee(config));
127 let mut editor = Editor::new(
127 let mut editor = Editor::new(
128 compositor.size(),
128 compositor.size(),
@@ -141,26 +141,28 @@ impl Application {
142 if args.load_tutor {
142 if args.load_tutor {
143 let path = helix_loader::runtime_dir().join("tutor.txt");
143 let path = helix_loader::runtime_dir().join("tutor.txt");
144− editor.open(path, Action::VerticalSplit)?;
144+ editor.open(&path, Action::VerticalSplit)?;
145 // Unset path to prevent accidentally saving to the original tutor file.
145 // Unset path to prevent accidentally saving to the original tutor file.
146 doc_mut!(editor).set_path(None)?;
146 doc_mut!(editor).set_path(None)?;
147 } else if !args.files.is_empty() {
147 } else if !args.files.is_empty() {
148 let first = &args.files[0].0; // we know it's not empty
148 let first = &args.files[0].0; // we know it's not empty
149 if first.is_dir() {
149 if first.is_dir() {
150− std::env::set_current_dir(&first)?;
150+ std::env::set_current_dir(&first).context("set current dir")?;
151 editor.new_file(Action::VerticalSplit);
151 editor.new_file(Action::VerticalSplit);
152 let picker = ui::file_picker(".".into(), &config.load().editor);
152 let picker = ui::file_picker(".".into(), &config.load().editor);
153 compositor.push(Box::new(overlayed(picker)));
153 compositor.push(Box::new(overlayed(picker)));
155 let nr_of_files = args.files.len();
155 let nr_of_files = args.files.len();
156− editor.open(first.to_path_buf(), Action::VerticalSplit)?;
156+ editor.open(first, Action::VerticalSplit)?;
157 for (file, pos) in args.files {
157 for (file, pos) in args.files {
158 if file.is_dir() {
158 if file.is_dir() {
159 return Err(anyhow::anyhow!(
159 return Err(anyhow::anyhow!(
160 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
160 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
163− let doc_id = editor.open(file, Action::Load)?;
164+ .open(&file, Action::Load)
165+ .context(format!("open '{}'", file.to_string_lossy()))?;
164 // with Action::Load all documents have the same view
166 // with Action::Load all documents have the same view
165 let view_id = editor.tree.focus;
167 let view_id = editor.tree.focus;
166 let doc = editor.document_mut(doc_id).unwrap();
168 let doc = editor.document_mut(doc_id).unwrap();
@@ -192,7 +194,8 @@ impl Application {
192 #[cfg(windows)]
194 #[cfg(windows)]
193 let signals = futures_util::stream::empty();
195 let signals = futures_util::stream::empty();
194 #[cfg(not(windows))]
196 #[cfg(not(windows))]
195− let signals = Signals::new(&[signal::SIGTSTP, signal::SIGCONT])?;
198+ Signals::new(&[signal::SIGTSTP, signal::SIGCONT]).context("build signal handler")?;
197 let app = Self {
200 let app = Self {
198 compositor,
201 compositor,