branch: elpa/subed commit e06563288f0a33942b310eb1e412749bcdf13be0 Author: Sacha Chua <sa...@sachachua.com> Commit: Sacha Chua <sa...@sachachua.com>
Fix previous commit for subed-set-subtitle-text * subed/subed-common.el (subed-set-subtitle-text): Remove unneccessary new function that got included. (subed-split-subtitle): Remove subed-set-subtitle-text. * tests/test-subed-common.el ("Splitting subtitles"): Add test case for empty subtitle. --- subed/subed-common.el | 13 ++----------- tests/test-subed-common.el | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/subed/subed-common.el b/subed/subed-common.el index a3ea291..5b5be90 100644 --- a/subed/subed-common.el +++ b/subed/subed-common.el @@ -621,16 +621,6 @@ following manner: (subed-regenerate-ids-soon)) (point)) -(defun subed-set-subtitle-text (text &optional sub-id) - "Set subtitle text to TEXT. - -If SUB-ID is not given, set the text of the current subtitle. - -Return the new subtitle text." - (delete-region (subed-jump-to-subtitle-text sub-id) - (or (subed-jump-to-subtitle-end sub-id) (point))) - (insert text)) - (defun subed-split-subtitle (&optional offset) "Split current subtitle at point. @@ -685,7 +675,8 @@ position of the point." (new-text (string-trim (buffer-substring (point) text-end))) (new-start-timestamp (+ split-timestamp subed-subtitle-spacing))) (subed-set-subtitle-time-stop split-timestamp) - (subed-set-subtitle-text (string-trim (buffer-substring-no-properties text-beg (point)))) + (delete-region (point) (progn (subed-jump-to-subtitle-end) (skip-chars-forward " \t") (point))) + (when (looking-at "[ \t]+") (replace-match "")) (subed-append-subtitle nil new-start-timestamp orig-end (string-trim new-text))) (subed-regenerate-ids-soon) (point))) diff --git a/tests/test-subed-common.el b/tests/test-subed-common.el index d6266eb..5bb3cc3 100644 --- a/tests/test-subed-common.el +++ b/tests/test-subed-common.el @@ -2134,6 +2134,24 @@ Baz. ) (describe "Splitting subtitles" + (it "handles empty subtitles" + (with-temp-srt-buffer + (insert "1 +00:01:23,000 --> 00:02:34,567 + +") + (forward-line -1) + (let ((subed-subtitle-spacing 100)) + (subed-split-subtitle 100)) + (expect (buffer-string) :to-equal +"1 +00:01:23,000 --> 00:01:23,100 + + +0 +00:01:23,200 --> 00:02:34,567 + +"))) (describe "when there are multiple lines" :var ((text "1 00:01:23,000 --> 00:02:34,567