aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-10-17 01:40:40 +0000
committerSkyler Hawthorne2022-10-19 02:31:39 +0000
commite645804b0a8e42c9fb9ef8259a9b2ad47a57a6e6 (patch)
tree37aa2579e0dd2b91f4c506882874730d3f41161c /helix-term/src
parent52ba550098745b463f59211a0172c334daef350b (diff)
Editor::flush_writes returns an error
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/application.rs5
-rw-r--r--helix-term/src/commands/typed.rs23
-rw-r--r--helix-term/src/compositor.rs4
3 files changed, 16 insertions, 16 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 6ca5b657..b4b4a675 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -977,7 +977,10 @@ impl Application {
errs.push(err);
};
- self.editor.flush_writes().await;
+ if let Err(err) = self.editor.flush_writes().await {
+ log::error!("Error writing: {}", err);
+ errs.push(err);
+ }
if self.editor.close_language_servers(None).await.is_err() {
log::error!("Timed out waiting for language servers to shutdown");
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index c18f3c39..eeeb4625 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -75,17 +75,16 @@ fn open(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
}
fn buffer_close_by_ids_impl(
- editor: &mut Editor,
+ cx: &mut compositor::Context,
doc_ids: &[DocumentId],
force: bool,
) -> anyhow::Result<()> {
- // TODO: deduplicate with ctx.block_try_flush_writes
- tokio::task::block_in_place(|| helix_lsp::block_on(editor.flush_writes()));
+ cx.block_try_flush_writes()?;
let (modified_ids, modified_names): (Vec<_>, Vec<_>) = doc_ids
.iter()
.filter_map(|&doc_id| {
- if let Err(CloseError::BufferModified(name)) = editor.close_document(doc_id, force) {
+ if let Err(CloseError::BufferModified(name)) = cx.editor.close_document(doc_id, force) {
Some((doc_id, name))
} else {
None
@@ -94,11 +93,11 @@ fn buffer_close_by_ids_impl(
.unzip();
if let Some(first) = modified_ids.first() {
- let current = doc!(editor);
+ let current = doc!(cx.editor);
// If the current document is unmodified, and there are modified
// documents, switch focus to the first modified doc.
if !modified_ids.contains(&current.id()) {
- editor.switch(*first, Action::Replace);
+ cx.editor.switch(*first, Action::Replace);
}
bail!(
"{} unsaved buffer(s) remaining: {:?}",
@@ -157,7 +156,7 @@ fn buffer_close(
}
let document_ids = buffer_gather_paths_impl(cx.editor, args);
- buffer_close_by_ids_impl(cx.editor, &document_ids, false)
+ buffer_close_by_ids_impl(cx, &document_ids, false)
}
fn force_buffer_close(
@@ -170,7 +169,7 @@ fn force_buffer_close(
}
let document_ids = buffer_gather_paths_impl(cx.editor, args);
- buffer_close_by_ids_impl(cx.editor, &document_ids, true)
+ buffer_close_by_ids_impl(cx, &document_ids, true)
}
fn buffer_gather_others_impl(editor: &mut Editor) -> Vec<DocumentId> {
@@ -192,7 +191,7 @@ fn buffer_close_others(
}
let document_ids = buffer_gather_others_impl(cx.editor);
- buffer_close_by_ids_impl(cx.editor, &document_ids, false)
+ buffer_close_by_ids_impl(cx, &document_ids, false)
}
fn force_buffer_close_others(
@@ -205,7 +204,7 @@ fn force_buffer_close_others(
}
let document_ids = buffer_gather_others_impl(cx.editor);
- buffer_close_by_ids_impl(cx.editor, &document_ids, true)
+ buffer_close_by_ids_impl(cx, &document_ids, true)
}
fn buffer_gather_all_impl(editor: &mut Editor) -> Vec<DocumentId> {
@@ -222,7 +221,7 @@ fn buffer_close_all(
}
let document_ids = buffer_gather_all_impl(cx.editor);
- buffer_close_by_ids_impl(cx.editor, &document_ids, false)
+ buffer_close_by_ids_impl(cx, &document_ids, false)
}
fn force_buffer_close_all(
@@ -235,7 +234,7 @@ fn force_buffer_close_all(
}
let document_ids = buffer_gather_all_impl(cx.editor);
- buffer_close_by_ids_impl(cx.editor, &document_ids, true)
+ buffer_close_by_ids_impl(cx, &document_ids, true)
}
fn buffer_next(
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index 76703780..971dc52d 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -32,9 +32,7 @@ impl<'a> Context<'a> {
/// operations for all documents.
pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> {
tokio::task::block_in_place(|| helix_lsp::block_on(self.jobs.finish(self.editor, None)))?;
-
- tokio::task::block_in_place(|| helix_lsp::block_on(self.editor.flush_writes()));
-
+ tokio::task::block_in_place(|| helix_lsp::block_on(self.editor.flush_writes()))?;
Ok(())
}
}