Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dhardy
Copy link
Contributor

@dhardy dhardy commented Sep 1, 2025

No description provided.

impl Events for Self {
type Data = ();

fn steal_event(&mut self, cx: &mut EventCx, _: &(), _: &Id, event: &Event) -> IsUsed {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't supported any more, as such we cannot intercept the Enter key and use it to navigate down/up.

Something else is needed. Considering the hacky nature and that nothing else uses event stealing, this was not the right approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is #20.

Comment on lines +125 to +176
impl DataClerk<usize> for EntriesClerk {
type Data = ContainsCaseInsensitive;
type Key = usize;
type Item = Entry;
type Token = usize;

fn update(&mut self, _: &mut ConfigCx, _: Id, filter: &Self::Data) -> DataChanges {
// TODO(opt) determine when updates are a no-op and return DataChanges::None

self.filtered_entries = self
.entries
.iter()
.enumerate()
.filter(|(_, opt)| {
opt.as_ref()
.map(|entry| filter.matches(entry))
.unwrap_or(false)
})
.map(|(i, _)| i)
.collect();

DataChanges::Any
}

fn len(&self, _: &Self::Data, _: usize) -> DataLen<usize> {
DataLen::Known(self.filtered_entries.len())
}

fn update_token(
&self,
_: &Self::Data,
index: usize,
_: bool,
token: &mut Option<usize>,
) -> TokenChanges {
let key = self.filtered_entries.get(index).cloned();
if *token == key {
TokenChanges::None
} else {
*token = key;
TokenChanges::Any
}
}

fn item(&self, _: &Self::Data, key: &usize) -> &Entry {
self.entries
.get(*key)
.map(|inner| inner.as_ref())
.flatten()
.unwrap()
}
}
Copy link
Contributor Author

@dhardy dhardy Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inelegant: DataClerk is a tedious low-level interface. The higher-level DataGenerator trait doesn't seem appropriate considering we can reference entries. Not very important.

We also need to use .unwrap() in fn item since the result is no longer an Option. Missing items when a token is available is a bug, but should such a bug force a panic in user code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but should such a bug force a panic in user code?

Decision: yes. The code in map_view_widgets would need some adaptation were fn item to return an Option, and since this case is a bug, it makes little sense to adjust.

@dhardy dhardy merged commit ace5a70 into master Sep 8, 2025
1 check passed
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.

2 participants