aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-10-16 09:01:31 +0000
committerSkyler Hawthorne2022-10-19 02:31:39 +0000
commitb0212b36118f7a4d596510dabb0c011144c7af69 (patch)
treeca01cfc38639facdd93ae1eb176290eb5f6f4b34 /helix-term/src
parent30c93994b50888aaeb32c65c90426e997800ccea (diff)
Deduplicate flush_writes
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/application.rs19
-rw-r--r--helix-term/src/commands/typed.rs17
-rw-r--r--helix-term/src/compositor.rs18
3 files changed, 4 insertions, 50 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 6010e745..719683bf 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -1,5 +1,5 @@
use arc_swap::{access::Map, ArcSwap};
-use futures_util::{Stream, StreamExt};
+use futures_util::Stream;
use helix_core::{
diagnostic::{DiagnosticTag, NumberOrString},
path::get_relative_path,
@@ -969,22 +969,7 @@ impl Application {
let mut errs = Vec::new();
// TODO: deduplicate with ctx.block_try_flush_writes
- tokio::task::block_in_place(|| {
- helix_lsp::block_on(async {
- while let Some(save_event) = self.editor.save_queue.next().await {
- match &save_event {
- Ok(event) => {
- let doc = doc_mut!(self.editor, &event.doc_id);
- doc.set_last_saved_revision(event.revision);
- }
- Err(err) => {
- log::error!("error saving document: {}", err);
- }
- };
- // TODO: if is_err: break?
- }
- })
- });
+ tokio::task::block_in_place(|| helix_lsp::block_on(self.editor.flush_writes()));
if let Err(err) = self
.jobs
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index ef774256..c18f3c39 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -80,22 +80,7 @@ fn buffer_close_by_ids_impl(
force: bool,
) -> anyhow::Result<()> {
// TODO: deduplicate with ctx.block_try_flush_writes
- tokio::task::block_in_place(|| {
- helix_lsp::block_on(async {
- while let Some(save_event) = editor.save_queue.next().await {
- match &save_event {
- Ok(event) => {
- let doc = doc_mut!(editor, &event.doc_id);
- doc.set_last_saved_revision(event.revision);
- }
- Err(err) => {
- log::error!("error saving document: {}", err);
- }
- };
- // TODO: if is_err: break?
- }
- })
- });
+ tokio::task::block_in_place(|| helix_lsp::block_on(editor.flush_writes()));
let (modified_ids, modified_names): (Vec<_>, Vec<_>) = doc_ids
.iter()
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index a4ffaff2..76703780 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -1,4 +1,3 @@
-use futures_util::StreamExt;
// Each component declares it's own size constraints and gets fitted based on it's parent.
// Q: how does this work with popups?
// cursive does compositor.screen_mut().add_layer_at(pos::absolute(x, y), <component>)
@@ -34,22 +33,7 @@ impl<'a> Context<'a> {
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(async {
- while let Some(save_event) = self.editor.save_queue.next().await {
- match &save_event {
- Ok(event) => {
- let doc = doc_mut!(self.editor, &event.doc_id);
- doc.set_last_saved_revision(event.revision);
- }
- Err(err) => {
- log::error!("error saving document: {}", err);
- }
- };
- // TODO: if is_err: break?
- }
- })
- });
+ tokio::task::block_in_place(|| helix_lsp::block_on(self.editor.flush_writes()));
Ok(())
}