on master help sign in
remove Callback::Compositor variant
b530a86Skyler Hawthorne
helix-term/src/application.rs+1−1
@@ -991,7 +991,7 @@ impl Application {
991
991
992 let mut result = match self
992 let mut result = match self
993 .jobs
993 .jobs
994− .finish(Some(&mut self.editor), Some(&mut self.compositor))
994+ .finish(&mut self.editor, Some(&mut self.compositor))
995 .await
995 .await
996 {
996 {
997 Ok(_) => Ok(()),
997 Ok(_) => Ok(()),
helix-term/src/commands/dap.rs+10−8
@@ -277,10 +277,11 @@ pub fn dap_launch(cx: &mut Context) {
277 let completions = template.completion.clone();
277 let completions = template.completion.clone();
278 let name = template.name.clone();
278 let name = template.name.clone();
279 let callback = Box::pin(async move {
279 let callback = Box::pin(async move {
280+ let call: Callback =
280− let call: Callback = Callback::Compositor(Box::new(move |compositor| {
281+ Callback::EditorCompositor(Box::new(move |_editor, compositor| {
281− let prompt = debug_parameter_prompt(completions, name, Vec::new());
282+ let prompt = debug_parameter_prompt(completions, name, Vec::new());
282− compositor.push(Box::new(prompt));
283+ compositor.push(Box::new(prompt));
283− }));
284+ }));
284 Ok(call)
285 Ok(call)
285 });
286 });
286 cx.jobs.callback(callback);
287 cx.jobs.callback(callback);
@@ -335,10 +336,11 @@ fn debug_parameter_prompt(
335 let config_name = config_name.clone();
336 let config_name = config_name.clone();
336 let params = params.clone();
337 let params = params.clone();
337 let callback = Box::pin(async move {
338 let callback = Box::pin(async move {
339+ let call: Callback =
338− let call: Callback = Callback::Compositor(Box::new(move |compositor| {
340+ Callback::EditorCompositor(Box::new(move |_editor, compositor| {
339− let prompt = debug_parameter_prompt(completions, config_name, params);
341+ let prompt = debug_parameter_prompt(completions, config_name, params);
340− compositor.push(Box::new(prompt));
342+ compositor.push(Box::new(prompt));
341− }));
343+ }));
342 Ok(call)
344 Ok(call)
343 });
345 });
344 cx.jobs.callback(callback);
346 cx.jobs.callback(callback);
helix-term/src/compositor.rs+1−3
@@ -31,9 +31,7 @@ impl<'a> Context<'a> {
31 /// Waits on all pending jobs, and then tries to flush all pending write
31 /// Waits on all pending jobs, and then tries to flush all pending write
32 /// operations for all documents.
32 /// operations for all documents.
33 pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> {
33 pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> {
34− tokio::task::block_in_place(|| {
35− helix_lsp::block_on(self.jobs.finish(Some(self.editor), None))
34+ tokio::task::block_in_place(|| helix_lsp::block_on(self.jobs.finish(self.editor, None)))?;
36− })?;
37
35
38 for doc in &mut self.editor.documents.values_mut() {
36 for doc in &mut self.editor.documents.values_mut() {
39 tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
37 tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
helix-term/src/job.rs+4−16
@@ -8,7 +8,6 @@ use futures_util::stream::{FuturesUnordered, StreamExt};
8pub enum Callback {
8pub enum Callback {
9 EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
9 EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
10 Editor(Box<dyn FnOnce(&mut Editor) + Send>),
10 Editor(Box<dyn FnOnce(&mut Editor) + Send>),
11− Compositor(Box<dyn FnOnce(&mut Compositor) + Send>),
12}
11}
13
12
14pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
13pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
@@ -76,7 +75,6 @@ impl Jobs {
76 Ok(Some(call)) => match call {
75 Ok(Some(call)) => match call {
77 Callback::EditorCompositor(call) => call(editor, compositor),
76 Callback::EditorCompositor(call) => call(editor, compositor),
78 Callback::Editor(call) => call(editor),
77 Callback::Editor(call) => call(editor),
79− Callback::Compositor(call) => call(compositor),
80 },
78 },
81 Err(e) => {
79 Err(e) => {
82 editor.set_error(format!("Async job failed: {}", e));
80 editor.set_error(format!("Async job failed: {}", e));
@@ -102,7 +100,7 @@ impl Jobs {
102 /// Blocks until all the jobs that need to be waited on are done.
100 /// Blocks until all the jobs that need to be waited on are done.
103 pub async fn finish(
101 pub async fn finish(
104 &mut self,
102 &mut self,
105− mut editor: Option<&mut Editor>,
103+ editor: &mut Editor,
106 mut compositor: Option<&mut Compositor>,
104 mut compositor: Option<&mut Compositor>,
107 ) -> anyhow::Result<()> {
105 ) -> anyhow::Result<()> {
108 log::debug!("waiting on jobs...");
106 log::debug!("waiting on jobs...");
@@ -117,20 +115,10 @@ impl Jobs {
117 // clippy doesn't realize this is an error without the derefs
115 // clippy doesn't realize this is an error without the derefs
118 #[allow(clippy::needless_option_as_deref)]
116 #[allow(clippy::needless_option_as_deref)]
119 match callback {
117 match callback {
120− Callback::EditorCompositor(call)
118+ Callback::EditorCompositor(call) if compositor.is_some() => {
121− if editor.is_some() && compositor.is_some() =>
122− {
123− call(
124− editor.as_deref_mut().unwrap(),
125− compositor.as_deref_mut().unwrap(),
126− )
127− }
128− Callback::Editor(call) if editor.is_some() => {
129− call(editor.as_deref_mut().unwrap())
130− }
131− Callback::Compositor(call) if compositor.is_some() => {
132− call(compositor.as_deref_mut().unwrap())
119+ call(editor, compositor.as_deref_mut().unwrap())
133 }
120 }
121+ Callback::Editor(call) => call(editor),
134
122
135 // skip callbacks for which we don't have the necessary references
123 // skip callbacks for which we don't have the necessary references
136 _ => (),
124 _ => (),
helix-term/src/ui/editor.rs+4−3
@@ -945,9 +945,10 @@ impl EditorView {
945
945
946 // TODO: Use an on_mode_change hook to remove signature help
946 // TODO: Use an on_mode_change hook to remove signature help
947 cxt.jobs.callback(async {
947 cxt.jobs.callback(async {
948− let call: job::Callback = Callback::Compositor(Box::new(|compositor| {
948+ let call: job::Callback =
949+ Callback::EditorCompositor(Box::new(|_editor, compositor| {
949− compositor.remove(SignatureHelp::ID);
950+ compositor.remove(SignatureHelp::ID);
950− }));
951+ }));
951 Ok(call)
952 Ok(call)
952 });
953 });
953 }
954 }