diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index a567815fc..36cb295ce 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -175,7 +175,7 @@ pub fn new(args: Args, config: Config, lang_loader: syntax::Loader) -> Result Result Action::HorizontalSplit, None => Action::Load, }; + let old_id = editor.document_id_by_path(&file); let doc_id = match editor.open(&file, action) { // Ignore irregular files during application init. Err(DocumentOpenError::IrregularFile) => { @@ -196,6 +197,11 @@ pub fn new(args: Args, config: Config, lang_loader: syntax::Loader) -> Result return Err(anyhow::anyhow!(err)), + // We can't open more than 1 buffer for 1 file, in this case we already have opened this file previously + Ok(doc_id) if old_id == Some(doc_id) => { + nr_of_files -= 1; + doc_id + } Ok(doc_id) => doc_id, }; // with Action::Load all documents have the same view diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index a3a27a076..516bfd7c3 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -154,8 +154,7 @@ async fn main_impl() -> Result { }); // TODO: use the thread local executor to spawn the application task separately from the work pool - let mut app = - Application::new(args, config, lang_loader).context("unable to create new application")?; + let mut app = Application::new(args, config, lang_loader).context("unable to start Helix")?; let exit_code = app.run(&mut EventStream::new()).await?; diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index aa9a11533..4fc3f4700 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1718,10 +1718,14 @@ pub fn new_file_from_stdin(&mut self, action: Action) -> Result Option { + self.document_by_path(path).map(|doc| doc.id) + } + // ??? possible use for integration tests pub fn open(&mut self, path: &Path, action: Action) -> Result { let path = helix_stdx::path::canonicalize(path); - let id = self.document_by_path(&path).map(|doc| doc.id); + let id = self.document_id_by_path(&path); let id = if let Some(id) = id { id