mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-15 19:28:00 +01:00
Fix loading of asciicast v1
This commit is contained in:
@@ -193,10 +193,10 @@ mod tests {
|
||||
assert_eq!(events[0].time, 1);
|
||||
assert!(matches!(events[0].data, EventData::Output(ref s) if s == "ż"));
|
||||
|
||||
assert_eq!(events[1].time, 1000000);
|
||||
assert_eq!(events[1].time, 10000001);
|
||||
assert!(matches!(events[1].data, EventData::Output(ref s) if s == "ółć"));
|
||||
|
||||
assert_eq!(events[2].time, 10500000);
|
||||
assert_eq!(events[2].time, 10500001);
|
||||
assert!(matches!(events[2].data, EventData::Output(ref s) if s == "\r\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ pub fn load(json: String) -> Result<Asciicast<'static>> {
|
||||
env: asciicast.env.clone(),
|
||||
};
|
||||
|
||||
let events = Box::new(
|
||||
asciicast
|
||||
.stdout
|
||||
.into_iter()
|
||||
.map(|e| Ok(Event::output(e.time, e.data))),
|
||||
);
|
||||
let events = Box::new(asciicast.stdout.into_iter().scan(0, |prev_time, event| {
|
||||
let time = *prev_time + event.time;
|
||||
*prev_time = time;
|
||||
|
||||
Some(Ok(Event::output(time, event.data)))
|
||||
}));
|
||||
|
||||
Ok(Asciicast { header, events })
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
"ż"
|
||||
],
|
||||
[
|
||||
1.000000,
|
||||
10.00,
|
||||
"ółć"
|
||||
],
|
||||
[
|
||||
10.500000,
|
||||
0.5,
|
||||
"\r\n"
|
||||
]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user