subed icon indicating copy to clipboard operation
subed copied to clipboard

[bug] Calling subed-merge-dwim (M-m) on a subtitle which has a line with only digits makes the digits disappear

Open rodrigomorales1 opened this issue 1 month ago • 0 comments

  • Steps to reproduce the bug
  • What happened?
  • What should have happened?
  • Additional information

Brief description of the bug

When a subtitle has multiple lines, and the last line of that subtitle only contains digits and subed-merge-dwim (by default, bound to M-m) is called on that subtitle, the line with only digits disappear.

Steps to reproduce the bug

I cloned the latest commit of the repository to make sure that I was using the latest changes.

rm -rf /tmp/subed && \
  mkdir /tmp/subed && \
  git clone --branch main --depth 1 https://github.com/sachac/subed /tmp/subed/subed-repo

I inserted the content of the code block below to the file /tmp/subed/a.srt.

1
00:00:00,000 --> 00:00:01,000
This is first subtitle.

2
00:00:01,000 --> 00:00:02,000
This is the second subtitle.

3
00:00:02,000 --> 00:00:03,000
This is the third subtitle.

4
00:00:03,000 --> 00:00:04,000
This is the fourth subtitle.

5
00:00:04,000 --> 00:00:05,000
123456789

6
00:00:05,000 --> 00:00:06,000
This is the sixth subtitle.

I compiled GNU Emacs 29.4 (latest release as of time of writing) and started Emacs using the command in the code block below.

I set EMACSLOADPATH and EMACSNATIVELOADPATH to an empty value to avoid my system configuration from modifying the default behavior of Emacs.

cd /my-storage/miscellaneous/source-code-popular/emacs && \
  EMACSLOADPATH= EMACSNATIVELOADPATH= ./src/emacs \
               --quick \
               --no-splash \
               --eval "(add-to-list 'load-path \"/tmp/subed/subed-repo/subed/\")" \
               --eval "(require 'subed-srt)" \
               --eval "(find-file \"/tmp/subed/a.srt\")"

When the Emacs window was opened, the point was at the beginning of the buffer. I moved the point to the line This is the first subtitle. I pressed M-m (by default, bound to subed-merge-dwim) twice. The contents of the buffer a.srt after performing that operation are shown below:

1
00:00:00,000 --> 00:00:03,000
This is first subtitle.
This is the second subtitle.
This is the third subtitle.

2
00:00:03,000 --> 00:00:04,000
This is the fourth subtitle.

3
00:00:04,000 --> 00:00:05,000
123456789

4
00:00:05,000 --> 00:00:06,000
This is the sixth subtitle.

I then moved the point to the line This is the fourth subtitle and called M-m (by default, bound to subed-merge-dwim) once. The contents of the buffer a.srt after performing that operation are shown below:

1
00:00:00,000 --> 00:00:03,000
This is first subtitle.
This is the second subtitle.
This is the third subtitle.

2
00:00:03,000 --> 00:00:05,000
This is the fourth subtitle.
123456789

3
00:00:05,000 --> 00:00:05,800
This is the sixth subtitle.

I pressed M-w again and the contents of the buffer were:

1
00:00:00,000 --> 00:00:03,000
This is first subtitle.
This is the second subtitle.
This is the third subtitle.

2
00:00:03,000 --> 00:00:05,800
This is the fourth subtitle.
This is the sixth subtitle.

What happened?

The subtitle whose content was 123456789 got deleted when calling subed-merge-dwim.

What should have happened?

The subtitle whose content was 12345789 should not have been deleted after calling subed-merge-dwim. That is, the content of the buffer should have been the following:

1
00:00:00,000 --> 00:00:03,000
This is first subtitle.
This is the second subtitle.
This is the third subtitle.

2
00:00:03,000 --> 00:00:05,800
This is the fourth subtitle.
1234566789
This is the sixth subtitle.

Additional information

  1. I found this bug because I was editing the subtitles for an audio that belongs to a chapter in a book on learning Spanish. In that chapter, students are introduced to how numbers are read in Spanish, so in the audio the speaker only mentions numbers and the subtitles contain the digits that correspond to those numbers. I believe it is not unusual for a subtitle to only contain numbers. For this reason, subed should handle subtitles that only contain digits properly.

  2. I opened the file and I loaded the theme modus-vivendi. I noticed that the content of the subtitle with index 5 was shown with the same face for the index of the subtitles. See screenshot below.

image

rodrigomorales1 avatar Jul 02 '24 04:07 rodrigomorales1