From 6851206b366fac25102e32012f3d1c1198bb9999 Mon Sep 17 00:00:00 2001 From: Steve Golton Date: Fri, 24 Jan 2025 18:39:17 +0000 Subject: [PATCH] ui: Treat events with undefined dur as instants when zooming/marking Change-Id: Ic5f3f4102feaa11dc4a13868bcffb85081bd529c --- ui/src/core/selection_manager.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ui/src/core/selection_manager.ts b/ui/src/core/selection_manager.ts index 56144b1b7a..fb54076795 100644 --- a/ui/src/core/selection_manager.ts +++ b/ui/src/core/selection_manager.ts @@ -458,12 +458,15 @@ export class SelectionManagerImpl implements SelectionManager { } } } else if (sel.kind === 'track_event') { - if (sel.dur === undefined) return undefined; - // Pretend incomplete slices are instants. The -1 duration here is just a - // flag, and doesn't actually represent the duration of the event. - // Besides, TimeSpan's will throw if created with a negative duration. - const dur = sel.dur === -1n ? 0n : sel.dur; - return TimeSpan.fromTimeAndDuration(sel.ts, dur); + switch (sel.dur) { + case undefined: + case -1n: + // Events without a duration or with duration -1 (DNF) slices are just + // treated as if they were instant events. + return TimeSpan.fromTimeAndDuration(sel.ts, 0n); + default: + return TimeSpan.fromTimeAndDuration(sel.ts, sel.dur); + } } return undefined;