Pass a &mut BlockContext when rendering blocks

This wraps and derefs to `RenderContext<Editor>`, so that we can
easily use `MouseEventHandler`s in blocks.
This commit is contained in:
Antonio Scandurra 2022-05-31 15:44:35 +02:00
parent 9fa03b2f28
commit aefdde66a6
4 changed files with 83 additions and 82 deletions

View file

@ -4745,7 +4745,7 @@ impl Editor {
height: 1,
render: Arc::new({
let editor = rename_editor.clone();
move |cx: &BlockContext| {
move |cx: &mut BlockContext| {
ChildView::new(editor.clone())
.contained()
.with_padding_left(cx.anchor_x)
@ -5866,7 +5866,7 @@ pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> Rend
highlighted_lines.push(highlight_diagnostic_message(line));
}
Arc::new(move |cx: &BlockContext| {
Arc::new(move |cx: &mut BlockContext| {
let settings = cx.global::<Settings>();
let theme = &settings.theme.editor;
let style = diagnostic_style(diagnostic.severity, is_valid, theme);