Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions app/src/notebooks/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub enum FileNotebookAction {
OpenAsCode,
ContextMenu(ContextMenuAction),
ToggleMarkdownDisplayMode(MarkdownDisplayMode),
ToggleMaximized,
}

impl From<ContextMenuAction> for FileNotebookAction {
Expand Down Expand Up @@ -919,6 +920,12 @@ impl TypedActionView for FileNotebookView {
}
}
}
FileNotebookAction::ToggleMaximized => {
ctx.emit(FileNotebookEvent::Pane(PaneEvent::ToggleMaximized));
self.pane_configuration.update(ctx, |pane_config, ctx| {
pane_config.refresh_pane_header_overflow_menu_items(ctx);
});
}
}
}
}
Expand All @@ -938,14 +945,24 @@ impl BackingView for FileNotebookView {

fn pane_header_overflow_menu_items(
&self,
_ctx: &AppContext,
ctx: &AppContext,
) -> Vec<MenuItem<FileNotebookAction>> {
let mut actions = vec![];
// Mirror the toggle that `CodeView` (the Raw markdown mode) exposes, so the Rendered
// markdown pane's overflow menu offers the same "Maximize pane" / "Minimize pane" entry.
let is_maximized = self
.focus_handle
.as_ref()
.is_some_and(|h| h.is_maximized(ctx));
let mut actions = vec![MenuItemFields::toggle_pane_action(is_maximized)
.with_on_select_action(FileNotebookAction::ToggleMaximized)
.into_item()];

if let Some(SourceFile::Local {
local_path: _local_path,
..
}) = self.file_state.source()
{
actions.push(MenuItem::Separator);
actions.push(
MenuItemFields::new("Refresh file")
.with_on_select_action(FileNotebookAction::ReloadFile)
Expand Down
41 changes: 41 additions & 0 deletions app/src/notebooks/file/mod_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use crate::{
};

use super::{FileNotebookView, FileState, MarkdownDisplayMode};
use crate::menu::MenuItem;
use crate::notebooks::context_menu::MenuSource;
use crate::pane_group::BackingView;
use warp_editor::render::model::BlockItem;

fn init_app(app: &mut App) {
Expand Down Expand Up @@ -279,3 +281,42 @@ fn test_file_notebook_mermaid_context_menu_does_not_show_copy_image() {
});
});
}

/// Regression test for GH#11256: the "Maximize pane" entry must appear in the overflow menu of
/// the rendered Markdown pane (`FileNotebookView`), matching the Raw mode (`CodeView`) behavior.
#[test]
fn test_rendered_markdown_overflow_menu_includes_maximize_pane() {
App::test((), |mut app| async move {
init_app(&mut app);
let (_, handle) = app.add_window(WindowStyle::NotStealFocus, FileNotebookView::new);
let session = Arc::new(Session::test());

handle
.update(&mut app, |file_notebook, ctx| {
file_notebook.open_local("../README.md", Some(session), ctx);
let file_id = file_notebook
.file_id
.expect("File should be opened and have a file_id");
let future_handle = FileModel::as_ref(ctx)
.get_future_handle(file_id)
.expect("Loading future should be present");
ctx.await_spawned_future(future_handle.future_id())
})
.await;

handle.read(&app, |view, ctx| {
let items = view.pane_header_overflow_menu_items(ctx);
let labels: Vec<&str> = items
.iter()
.filter_map(|item| match item {
MenuItem::Item(fields) => Some(fields.label()),
_ => None,
})
.collect();
assert!(
labels.contains(&"Maximize pane"),
"Rendered Markdown overflow menu should include 'Maximize pane', got: {labels:?}"
);
});
});
}