@@ -25,7 +25,7 @@ use std::{
2525 time::{Duration, Instant},
2626};
2727
28−use anyhow::Error;
28+use anyhow::{Context, Error};
2929
3030use crossterm::{
3131 event::{DisableMouseCapture, EnableMouseCapture, Event},
@@ -122,7 +122,7 @@ impl Application {
122122 });
123123 let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
124124
125− let mut compositor = Compositor::new()?;
125+ let mut compositor = Compositor::new().context("build compositor")?;
126126 let config = Arc::new(ArcSwap::from_pointee(config));
127127 let mut editor = Editor::new(
128128 compositor.size(),
@@ -141,26 +141,28 @@ impl Application {
141141
142142 if args.load_tutor {
143143 let path = helix_loader::runtime_dir().join("tutor.txt");
144− editor.open(path, Action::VerticalSplit)?;
144+ editor.open(&path, Action::VerticalSplit)?;
145145 // Unset path to prevent accidentally saving to the original tutor file.
146146 doc_mut!(editor).set_path(None)?;
147147 } else if !args.files.is_empty() {
148148 let first = &args.files[0].0; // we know it's not empty
149149 if first.is_dir() {
150− std::env::set_current_dir(&first)?;
150+ std::env::set_current_dir(&first).context("set current dir")?;
151151 editor.new_file(Action::VerticalSplit);
152152 let picker = ui::file_picker(".".into(), &config.load().editor);
153153 compositor.push(Box::new(overlayed(picker)));
154154 } else {
155155 let nr_of_files = args.files.len();
156− editor.open(first.to_path_buf(), Action::VerticalSplit)?;
156+ editor.open(first, Action::VerticalSplit)?;
157157 for (file, pos) in args.files {
158158 if file.is_dir() {
159159 return Err(anyhow::anyhow!(
160160 "expected a path to file, found a directory. (to open a directory pass it as first argument)"
161161 ));
162162 } else {
163− let doc_id = editor.open(file, Action::Load)?;
163+ let doc_id = editor
164+ .open(&file, Action::Load)
165+ .context(format!("open '{}'", file.to_string_lossy()))?;
164166 // with Action::Load all documents have the same view
165167 let view_id = editor.tree.focus;
166168 let doc = editor.document_mut(doc_id).unwrap();
@@ -192,7 +194,8 @@ impl Application {
192194 #[cfg(windows)]
193195 let signals = futures_util::stream::empty();
194196 #[cfg(not(windows))]
195− let signals = Signals::new(&[signal::SIGTSTP, signal::SIGCONT])?;
197+ let signals =
198+ Signals::new(&[signal::SIGTSTP, signal::SIGCONT]).context("build signal handler")?;
196199
197200 let app = Self {
198201 compositor,