mirror of https://github.com/helix-editor/helix
Merge pull request #29 from piotrkwarcinski/exp-picker-fix
Fix call to exp-picker callbackpull/8675/merge^2
commit
c5bd4518e1
|
@ -3985,37 +3985,41 @@ fn configure_engine_impl(mut engine: Engine) -> Engine {
|
||||||
let rooted = callback_fn.as_rooted();
|
let rooted = callback_fn.as_rooted();
|
||||||
|
|
||||||
let picker = ui::Picker::new(columns, 0, [], cwd, move |cx, path: &PathBuf, action| {
|
let picker = ui::Picker::new(columns, 0, [], cwd, move |cx, path: &PathBuf, action| {
|
||||||
if let Err(e) = cx.editor.open(path, action) {
|
let result = cx.editor.open(path, action);
|
||||||
let err = if let Some(err) = e.source() {
|
match result {
|
||||||
format!("{}", err)
|
Err(e) => {
|
||||||
} else {
|
let err = if let Some(err) = e.source() {
|
||||||
format!("unable to open \"{}\"", path.display())
|
format!("{}", err)
|
||||||
};
|
} else {
|
||||||
cx.editor.set_error(err);
|
format!("unable to open \"{}\"", path.display())
|
||||||
|
};
|
||||||
|
cx.editor.set_error(err);
|
||||||
|
}
|
||||||
|
Ok(_) => {
|
||||||
|
let mut ctx = Context {
|
||||||
|
register: None,
|
||||||
|
count: None,
|
||||||
|
editor: cx.editor,
|
||||||
|
callback: Vec::new(),
|
||||||
|
on_next_key_callback: None,
|
||||||
|
jobs: cx.jobs,
|
||||||
|
};
|
||||||
|
|
||||||
let mut ctx = Context {
|
let cloned_func = rooted.value();
|
||||||
register: None,
|
|
||||||
count: None,
|
|
||||||
editor: cx.editor,
|
|
||||||
callback: Vec::new(),
|
|
||||||
on_next_key_callback: None,
|
|
||||||
jobs: cx.jobs,
|
|
||||||
};
|
|
||||||
|
|
||||||
let cloned_func = rooted.value();
|
enter_engine(|guard| {
|
||||||
|
if let Err(e) = guard
|
||||||
enter_engine(|guard| {
|
.with_mut_reference::<Context, Context>(&mut ctx)
|
||||||
if let Err(e) = guard
|
.consume(move |engine, args| {
|
||||||
.with_mut_reference::<Context, Context>(&mut ctx)
|
let context = args[0].clone();
|
||||||
.consume(move |engine, args| {
|
engine.update_value("*helix.cx*", context);
|
||||||
let context = args[0].clone();
|
engine.call_function_with_args(cloned_func.clone(), Vec::new())
|
||||||
engine.update_value("*helix.cx*", context);
|
})
|
||||||
engine.call_function_with_args(cloned_func.clone(), Vec::new())
|
{
|
||||||
})
|
present_error_inside_engine_context(&mut ctx, guard, e);
|
||||||
{
|
}
|
||||||
present_error_inside_engine_context(&mut ctx, guard, e);
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.with_preview(|_editor, path| Some((PathOrId::Path(path), None)));
|
.with_preview(|_editor, path| Some((PathOrId::Path(path), None)));
|
||||||
|
|
Loading…
Reference in New Issue