mirror of https://github.com/helix-editor/helix
remove Callback::Compositor variant
To reduce likelihood of accidental discarding of important callbackspull/2267/head
parent
b3fc31a211
commit
b530a86d1f
|
@ -991,7 +991,7 @@ impl Application {
|
||||||
|
|
||||||
let mut result = match self
|
let mut result = match self
|
||||||
.jobs
|
.jobs
|
||||||
.finish(Some(&mut self.editor), Some(&mut self.compositor))
|
.finish(&mut self.editor, Some(&mut self.compositor))
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
|
|
|
@ -277,7 +277,8 @@ pub fn dap_launch(cx: &mut Context) {
|
||||||
let completions = template.completion.clone();
|
let completions = template.completion.clone();
|
||||||
let name = template.name.clone();
|
let name = template.name.clone();
|
||||||
let callback = Box::pin(async move {
|
let callback = Box::pin(async move {
|
||||||
let call: Callback = Callback::Compositor(Box::new(move |compositor| {
|
let call: Callback =
|
||||||
|
Callback::EditorCompositor(Box::new(move |_editor, compositor| {
|
||||||
let prompt = debug_parameter_prompt(completions, name, Vec::new());
|
let prompt = debug_parameter_prompt(completions, name, Vec::new());
|
||||||
compositor.push(Box::new(prompt));
|
compositor.push(Box::new(prompt));
|
||||||
}));
|
}));
|
||||||
|
@ -335,7 +336,8 @@ fn debug_parameter_prompt(
|
||||||
let config_name = config_name.clone();
|
let config_name = config_name.clone();
|
||||||
let params = params.clone();
|
let params = params.clone();
|
||||||
let callback = Box::pin(async move {
|
let callback = Box::pin(async move {
|
||||||
let call: Callback = Callback::Compositor(Box::new(move |compositor| {
|
let call: Callback =
|
||||||
|
Callback::EditorCompositor(Box::new(move |_editor, compositor| {
|
||||||
let prompt = debug_parameter_prompt(completions, config_name, params);
|
let prompt = debug_parameter_prompt(completions, config_name, params);
|
||||||
compositor.push(Box::new(prompt));
|
compositor.push(Box::new(prompt));
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -31,9 +31,7 @@ impl<'a> Context<'a> {
|
||||||
/// Waits on all pending jobs, and then tries to flush all pending write
|
/// Waits on all pending jobs, and then tries to flush all pending write
|
||||||
/// operations for all documents.
|
/// operations for all documents.
|
||||||
pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> {
|
pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> {
|
||||||
tokio::task::block_in_place(|| {
|
tokio::task::block_in_place(|| helix_lsp::block_on(self.jobs.finish(self.editor, None)))?;
|
||||||
helix_lsp::block_on(self.jobs.finish(Some(self.editor), None))
|
|
||||||
})?;
|
|
||||||
|
|
||||||
for doc in &mut self.editor.documents.values_mut() {
|
for doc in &mut self.editor.documents.values_mut() {
|
||||||
tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
|
tokio::task::block_in_place(|| helix_lsp::block_on(doc.try_flush_saves()))
|
||||||
|
|
|
@ -8,7 +8,6 @@ use futures_util::stream::{FuturesUnordered, StreamExt};
|
||||||
pub enum Callback {
|
pub enum Callback {
|
||||||
EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
|
EditorCompositor(Box<dyn FnOnce(&mut Editor, &mut Compositor) + Send>),
|
||||||
Editor(Box<dyn FnOnce(&mut Editor) + Send>),
|
Editor(Box<dyn FnOnce(&mut Editor) + Send>),
|
||||||
Compositor(Box<dyn FnOnce(&mut Compositor) + Send>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
|
pub type JobFuture = BoxFuture<'static, anyhow::Result<Option<Callback>>>;
|
||||||
|
@ -76,7 +75,6 @@ impl Jobs {
|
||||||
Ok(Some(call)) => match call {
|
Ok(Some(call)) => match call {
|
||||||
Callback::EditorCompositor(call) => call(editor, compositor),
|
Callback::EditorCompositor(call) => call(editor, compositor),
|
||||||
Callback::Editor(call) => call(editor),
|
Callback::Editor(call) => call(editor),
|
||||||
Callback::Compositor(call) => call(compositor),
|
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
editor.set_error(format!("Async job failed: {}", e));
|
editor.set_error(format!("Async job failed: {}", e));
|
||||||
|
@ -102,7 +100,7 @@ impl Jobs {
|
||||||
/// Blocks until all the jobs that need to be waited on are done.
|
/// Blocks until all the jobs that need to be waited on are done.
|
||||||
pub async fn finish(
|
pub async fn finish(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut editor: Option<&mut Editor>,
|
editor: &mut Editor,
|
||||||
mut compositor: Option<&mut Compositor>,
|
mut compositor: Option<&mut Compositor>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
log::debug!("waiting on jobs...");
|
log::debug!("waiting on jobs...");
|
||||||
|
@ -117,20 +115,10 @@ impl Jobs {
|
||||||
// clippy doesn't realize this is an error without the derefs
|
// clippy doesn't realize this is an error without the derefs
|
||||||
#[allow(clippy::needless_option_as_deref)]
|
#[allow(clippy::needless_option_as_deref)]
|
||||||
match callback {
|
match callback {
|
||||||
Callback::EditorCompositor(call)
|
Callback::EditorCompositor(call) if compositor.is_some() => {
|
||||||
if editor.is_some() && compositor.is_some() =>
|
call(editor, compositor.as_deref_mut().unwrap())
|
||||||
{
|
|
||||||
call(
|
|
||||||
editor.as_deref_mut().unwrap(),
|
|
||||||
compositor.as_deref_mut().unwrap(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Callback::Editor(call) if editor.is_some() => {
|
|
||||||
call(editor.as_deref_mut().unwrap())
|
|
||||||
}
|
|
||||||
Callback::Compositor(call) if compositor.is_some() => {
|
|
||||||
call(compositor.as_deref_mut().unwrap())
|
|
||||||
}
|
}
|
||||||
|
Callback::Editor(call) => call(editor),
|
||||||
|
|
||||||
// skip callbacks for which we don't have the necessary references
|
// skip callbacks for which we don't have the necessary references
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -945,7 +945,8 @@ impl EditorView {
|
||||||
|
|
||||||
// TODO: Use an on_mode_change hook to remove signature help
|
// TODO: Use an on_mode_change hook to remove signature help
|
||||||
cxt.jobs.callback(async {
|
cxt.jobs.callback(async {
|
||||||
let call: job::Callback = Callback::Compositor(Box::new(|compositor| {
|
let call: job::Callback =
|
||||||
|
Callback::EditorCompositor(Box::new(|_editor, compositor| {
|
||||||
compositor.remove(SignatureHelp::ID);
|
compositor.remove(SignatureHelp::ID);
|
||||||
}));
|
}));
|
||||||
Ok(call)
|
Ok(call)
|
||||||
|
|
Loading…
Reference in New Issue