Skip to content

refactor(menu)!: require Menu::settings instead of panicking in a default - #1215

Merged
kronberger-droid merged 3 commits into
nushell:mainfrom
kronberger-droid:chore/menu-settings-required
Sep 17, 2026
Merged

kronberger-droid merged 3 commits into
nushell:mainfrom
kronberger-droid:chore/menu-settings-required

Conversation

@kronberger-droid

Copy link
Copy Markdown
Collaborator

Summary

Menu::settings ships a default body that panics, added so menus written before MenuSettings kept compiling.
The default name and indicator read through settings(), and the engine looks a menu up by name on every menu event, so a menu that takes the default compiles and then panics the first time it is triggered.

Making the method required turns that guaranteed runtime panic into a compile error.

Breaking for Menu implementors outside reedline.
Every in-tree menu already implements it, and nushell has no Menu impls of its own.

Before

fn settings(&self) -> &MenuSettings {
    panic!("`settings` requires a manual implementation per menu. ...")
}

After

fn settings(&self) -> &MenuSettings;

Additional notes

The second commit gives the painter's TestMenu a real MenuSettings instead of an unimplemented!(), since the point is to stop menus carrying a panic where their settings should be.

The default body existed so that external menus written before
`MenuSettings` kept compiling, and then panicked on first use, since every
other default method on the trait reads through it. Nothing outside
reedline implements `Menu`, so the compile error is the cheaper failure.
@kronberger-droid
kronberger-droid marked this pull request as ready for review September 16, 2026 12:44
@kronberger-droid
kronberger-droid merged commit 4f4df98 into nushell:main Sep 17, 2026
7 checks passed
kronberger-droid added a commit that referenced this pull request Sep 17, 2026
…eam (#1220)

#1215 made `Menu::settings` required, but its return type lives in the
private `menu` module and was never re-exported. The panicking default
had hidden that: an external impl could simply leave the method out.
Without the export no crate outside reedline can implement `Menu`,
which broke nushell's `SourcedMenu` wrapper on the bump to e0f1c0b.
kronberger-droid added a commit to nushell/nushell that referenced this pull request Sep 17, 2026
## Description

Fixes the broken build on `main` after #19042.
nushell/reedline#1215 made `Menu::settings` a required method, and
`SourcedMenu` never forwarded it, so `nu-cli` stopped compiling.
This adds the forward and bumps reedline to c9e7035, which includes
nushell/reedline#1220 exporting `MenuSettings`, since without that
export the return type could not be named here.

## User-facing changes (Release notes)

## Additional notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant