Skip to content

refactor(menu): read the picked example through and_then instead of expect - #1174

Open
kronberger-droid wants to merge 1 commit into
nushell:mainfrom
kronberger-droid:refactor/description-menu-example-index
Open

refactor(menu): read the picked example through and_then instead of expect#1174
kronberger-droid wants to merge 1 commit into
nushell:mainfrom
kronberger-droid:refactor/description-menu-example-index

Conversation

@kronberger-droid

Copy link
Copy Markdown
Collaborator

Summary

DescriptionMenu::replace_in_buffer unwrapped example_index and then examples.get(..) with an expect.
The index is only ever set inside examples and reset when the list is rebuilt, so it held, but and_then asks the one question the fn has, is there a picked example, without a way to panic.
If the invariant ever slips the suggestion goes in unchanged instead of aborting on Enter.
No behaviour change, no public API change.

…xpect

`example_index` is only ever set inside `examples` and is reset whenever
the list is rebuilt, so the `expect` held. `and_then` asks the one question
`replace_in_buffer` has, is there a picked example, without a way to
panic; if the invariant ever slips the suggestion goes in unchanged.
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