Skip to content

feat: revert, clear and the source's own line, under the text box - #106

Merged
xAlcahest merged 1 commit into
mainfrom
line-buttons
Sep 6, 2026
Merged

feat: revert, clear and the source's own line, under the text box#106
xAlcahest merged 1 commit into
mainfrom
line-buttons

Conversation

@xAlcahest

Copy link
Copy Markdown
Owner

Summary

The row of four under the text box, which is where the reference puts it and where Sublore had nothing. Revert puts the line back to what it was when the cursor arrived on it. Clear empties it. Clear text keeps every braced run where it stands and drops only the words a reader sees. Insert original puts the source's line for that row where the caret is.

The two clears are one planner edit, Edit::ClearText { cue, keep_tags }, because keeping the runs needs the block scanner that already lives in sublore-formats and the difference between the two is one filter. They are their own edit kind, so a clear and the typing around it can never coalesce into one undo step.

Insert original is what M2.6's source document made possible: before it, the reference's own answer was a remembered string and Sublore had nothing to remember. It splices in UTF-8 bytes rather than code units, because the caret the backend reports is counted in bytes and a code-unit slice lands in the wrong place the moment a line carries a character outside the Latin block, which a translation usually does.

One thing came out of writing the checks: the condition the style buttons grey on wanted ASS, and Insert original is not a tag write, so the two are now separate. A caret on the cursor's row is what both need; only the tag writes additionally need a format that carries tags.

Changes

  • crates/sublore-edit/src/plan.rs: Edit::ClearText and plan_clear_text, which keeps every block that is not words when asked.
  • crates/sublore-edit/src/splice.rs: its own edit kind, so a clear never merges with the typing beside it.
  • crates/sublore-edit/tests/session.rs: the two clears told apart on a line with a tag, a note and words, and the undo between them.
  • src-tauri/src/subtitle/mod.rs and lib.rs: subtitle_clear_text, registered.
  • src/hooks/useSubtitleFile.ts: clearText.
  • src/App.tsx: the four commands, the row's text as it was when the cursor arrived, the UTF-8 splice, and the caret condition split from the tag condition.
  • src/components/CurrentLine.tsx: the row under the box.
  • src/i18n/en.ts and src/styles/tools.css: the four words and the row.
  • e2e/specs/current-line-bands.spec.js: the two clears and Revert, each leaving the document as it found it, and the fourth band in the panel's table.
  • e2e/specs/source-column.spec.js: the source's line put at the caret, undone, and the button greyed on a row the source does not reach.
  • e2e/specs/command-registry.spec.js: the four commands in the declared list, the Edit menu and the greying table.
  • e2e/wdio.conf.js: the count the guard holds.

How to verify it by using the app

  1. Open fixtures/subtitles/ass/clean/speakers.ass. Under the text box there are four buttons: Revert, Clear, Clear text, Insert original.
  2. Revert is greyed, because nothing has moved on this line since you arrived on it. Type something and click into the Comment box and back to commit it: Revert wakes. Click it and the line goes back to what it was.
  3. Type {\b1}bold{\b0} and plain into the box and commit it the same way. Click Clear text: the words go and {\b1}{\b0} stays. Click Clear: the rest goes too. Ctrl+Z once puts back exactly what Clear text left, because they are two steps.
  4. Insert original is greyed while no source is open. Open one with File, Open source subtitle.
  5. Put the caret at the start of the box and click Insert original: the source's line for that row appears there. Ctrl+Z takes it out in one step.
  6. Move to a row the source does not reach, put a caret in the box, and the button greys again.

Verified on Linux: full gate green step by step, and the battery green at 35 spec files of 35 with 291 checks. Two mutations each reddened its own check first, a Clear text that keeps the words instead of the runs, and an insert that lands at the end of the line instead of at the caret.

@xAlcahest
xAlcahest merged commit d6d34eb into main Sep 6, 2026
14 checks passed
@xAlcahest
xAlcahest deleted the line-buttons branch September 6, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant