mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
Fix event::print's header printing
Turns out doing `==` on Enums with values will do a deep comparison, including the values. So EventDescription::Signal(SIGTERM) is != EventDescription::Signal(SIGWINCH). That's not what we want here, so this does a bit of a roundabout thing.
This commit is contained in:
parent
4f86f303f5
commit
ee8e790aa7
2 changed files with 24 additions and 4 deletions
|
@ -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));
|
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 {
|
for evt in tmp {
|
||||||
// If we have a filter, skip events that don't match.
|
// If we have a filter, skip events that don't match.
|
||||||
if !evt.desc.matches_filter(type_filter) {
|
if !evt.desc.matches_filter(type_filter) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if last_type.as_ref() != Some(&evt.desc) {
|
// Print a "Event $TYPE" header for each event type.
|
||||||
if last_type.is_some() {
|
// 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"));
|
streams.out.append(L!("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
last_type = Some(evt.desc.clone());
|
last_type = std::mem::discriminant(&evt.desc);
|
||||||
streams
|
streams
|
||||||
.out
|
.out
|
||||||
.append(&sprintf!(L!("Event %ls\n"), evt.desc.name()));
|
.append(&sprintf!(L!("Event %ls\n"), evt.desc.name()));
|
||||||
|
|
|
@ -171,3 +171,17 @@ functions --no-details --details t
|
||||||
# CHECKERR: ^
|
# CHECKERR: ^
|
||||||
# CHECKERR: (Type 'help functions' for related documentation)
|
# CHECKERR: (Type 'help functions' for related documentation)
|
||||||
# XXX FIXME ^ caret should point at --no-details --details
|
# 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
|
||||||
|
|
Loading…
Reference in a new issue