diff --git a/fish-rust/src/event.rs b/fish-rust/src/event.rs index 80b1bf1d9..b2807b0a6 100644 --- a/fish-rust/src/event.rs +++ b/fish-rust/src/event.rs @@ -845,19 +845,25 @@ pub fn print(streams: &mut io_streams_t, type_filter: &wstr) { tmp.sort_by(|e1, e2| e1.desc.cmp(&e2.desc)); - let mut last_type = None; + let mut last_type = std::mem::discriminant(&EventDescription::Any); for evt in tmp { // If we have a filter, skip events that don't match. if !evt.desc.matches_filter(type_filter) { continue; } - if last_type.as_ref() != Some(&evt.desc) { - if last_type.is_some() { + // Print a "Event $TYPE" header for each event type. + // This compares only the event *type*, not the entire event, + // so we don't compare variable events for different variables as different. + // + // This assumes EventDescription::Any is not a valid value for an event to have + // - it's marked "unreachable!()" below! + if last_type != std::mem::discriminant(&evt.desc) { + if last_type != std::mem::discriminant(&EventDescription::Any) { streams.out.append(L!("\n")); } - last_type = Some(evt.desc.clone()); + last_type = std::mem::discriminant(&evt.desc); streams .out .append(&sprintf!(L!("Event %ls\n"), evt.desc.name())); diff --git a/tests/checks/functions.fish b/tests/checks/functions.fish index 06ea0967a..f5f0dae1d 100644 --- a/tests/checks/functions.fish +++ b/tests/checks/functions.fish @@ -171,3 +171,17 @@ functions --no-details --details t # CHECKERR: ^ # CHECKERR: (Type 'help functions' for related documentation) # XXX FIXME ^ caret should point at --no-details --details + +function term1 --on-signal TERM +end +function term2 --on-signal TERM +end +function term3 --on-signal TERM +end + +functions --handlers-type signal +# CHECK: Event signal +# CHECK: SIGTRAP fish_sigtrap_handler +# CHECK: SIGTERM term1 +# CHECK: SIGTERM term2 +# CHECK: SIGTERM term3