Vectrum
Sign In

Open the composer's context menu a tick later

The menu builder runs while the editor is mid-update, where reading its
state panics, so the real menu is built and shown on the next tick.
JjohannSocommitted 1 parent 5db34afcommit3917276

Showing 1 changed file with 11 additions and 1 deletion.

+11−1src/ui/markdown_input.rsView File
@@ -251,7 +251,17 @@ impl RenderOnce for MarkdownInput {
251251 Editor::new(&self.state)
252252 .appearance(false)
253253 .h(line_height * rows as f32 + px(PADDING_Y * 2.))
254- .context_menu(move |menu, _, cx| context_menu(&menu_state, menu, cx))
254+ .context_menu(move |menu, window, cx| {
255+ // The builder runs while the editor is mid-update, where
256+ // reading its state panics, so the real menu waits a tick
257+ // and the empty one returned here shows nothing.
258+ let state = menu_state.clone();
259+ window.defer(cx, move |window, cx| {
260+ let position = window.mouse_position();
261+ context_menu(&state, NativeMenu::new(), cx).show(position, window, cx);
262+ });
263+ menu
264+ })
255265 .font_family(metal::SANS)
256266 .text_size(rems(0.875))
257267 .line_height(rems(1.25))