[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed dc60c27 060/389: subed-srt--subtitle-id-at-msecs: Tr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed dc60c27 060/389: subed-srt--subtitle-id-at-msecs: Try to ignore invalid time stamps |
Date: |
Fri, 3 Dec 2021 10:59:57 -0500 (EST) |
branch: elpa/subed
commit dc60c27e16e34f6f60c97f5b852ef27f42c4e456
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
subed-srt--subtitle-id-at-msecs: Try to ignore invalid time stamps
---
subed/subed-srt.el | 4 ++--
tests/test-subed-srt.el | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index 5078deb..8a7d506 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -83,12 +83,12 @@ after MSECS if there is one and its start time is >= MSECS +
(re-search-forward (format "\\(\n\n\\|\\`\\)[0-9]+\n%02d:%02d"
only-hours only-mins) nil t)))
;; Move to first subtitle that starts at or after MSECS
(catch 'last-subtitle-reached
- (while (<= (subed-srt--subtitle-msecs-start) msecs)
+ (while (<= (or (subed-srt--subtitle-msecs-start) -1) msecs)
(unless (subed-srt-forward-subtitle-id)
(throw 'last-subtitle-reached nil))))
;; Move back to previous subtitle if start of current subtitle is in the
;; future (i.e. MSECS is between subtitles)
- (when (> (subed-srt--subtitle-msecs-start) msecs)
+ (when (> (or (subed-srt--subtitle-msecs-start) -1) msecs)
(subed-srt-backward-subtitle-id))
(subed-srt--subtitle-id))))
diff --git a/tests/test-subed-srt.el b/tests/test-subed-srt.el
index 044054e..129b001 100644
--- a/tests/test-subed-srt.el
+++ b/tests/test-subed-srt.el
@@ -88,6 +88,14 @@ Baz.
(progn
(subed-srt-move-to-subtitle-id
outset-id)
(expect
(subed-srt--subtitle-id-at-msecs msecs) :to-equal target-id)))))))
+ (it "doesn't fail when start time is invalid."
+ (with-temp-buffer
+ (insert mock-srt-data)
+ (subed-srt-move-to-subtitle-id 2)
+ (let ((msecs (- (subed-srt--subtitle-msecs-start)
1)))
+ (subed-srt-move-to-subtitle-time-start)
+ (forward-char 8) (delete-char 1)
+ (expect (subed-srt--subtitle-id-at-msecs msecs)
:to-equal 2))))
)
(describe "the subtitle start/stop time"
(it "returns the time in milliseconds."
- [nongnu] elpa/subed 6cf5df4 036/389: Remove annoying minibuffer messages, (continued)
- [nongnu] elpa/subed 6cf5df4 036/389: Remove annoying minibuffer messages, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3927690 037/389: Some rewording, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 62d5d3d 038/389: Use (unless ...) instead of (when (not ...)), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 166988c 041/389: Special subtitle separator when moving to end of subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e471802 046/389: Adjust test description, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 727275d 043/389: subed-srt-sanitize: Wrap function body in atomic-change-group, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a30a4b1 054/389: subed-srt-regenerate-ids: Don't change buffer unless it's necessary, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5fd2009 055/389: subed-mpv: Handle invalid JSON, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c865969 058/389: Toggle subed-mode when `subed-mode' is called, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 65bfba6 057/389: When enabling debugging, expect the debug window to exist, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dc60c27 060/389: subed-srt--subtitle-id-at-msecs: Try to ignore invalid time stamps,
ELPA Syncer <=
- [nongnu] elpa/subed 0781285 061/389: Make mpv RPC socket and client buffer unique per buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 2f86a8e 030/389: Add function: subed-srt--subtitle-text, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 17f3ae5 034/389: Add/fix tests for srt parsing changes, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed fb9354c 039/389: Adjust tests for subed-srt-move-to-subtitle-end, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 4e3e42f 044/389: subed-srt-sort: Wrap function body in atomic-change-group, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 33f27c5 063/389: Fix docstring, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7932aee 066/389: subed-srt-sort: Sanitize before validating, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dc771c8 067/389: Fix/Add tests, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 23156e3 071/389: subed-srt-subtitle-insert: Make argument optional, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 0e05076 072/389: subed-srt-sanitize: Properly trim trailing newlines, ELPA Syncer, 2021/12/03