Repository navigation
Editor: edits keep untouched words' timing and vocabulary original - #36
Merged
Merged
Conversation
editSentence, editParagraph and replaceAll rebuilt the whole sentence with respread, so any edit (even opening an editor and leaving it unchanged) moved every word's timing and dropped `original`. Find & Replace of one word did the same to its whole sentence. They now align the old and new word lists (longest common subsequence, exact text) and keep each untouched word as it was. A run of new words that replaces old ones takes those words' time; a run inserted between kept words takes the gap between them. With nothing kept, the text spreads across the span as before. An edited vocabulary word still drops `original`; that choice belongs with the vocabulary underline step. Closes #28
…e match count From /simplify on #36; behaviour is unchanged (20,000 random edits compared against the previous commit came out identical). - retime(old, tokens) works out the span and speaker from `old`, so editParagraph loses its two span loops and editSentence becomes editParagraph on one sentence. - Flatter run timing: the replaced words' own time, else the gap between the kept neighbours, with `??` instead of nested ternaries. - keptPairs' comment says why the shared prefix and suffix are matched first: a smaller table, and the words at both ends stay matched when a repeated word could match in more than one place. - countReplacements gives replaceAll's count without building the new state. The editor's live match count used a full replaceAll on every keystroke, which now also re-timed each matching sentence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28.
What changed
editSentence,editParagraphandreplaceAll(core/src/editor.ts) rebuilt the whole sentence withrespread. Any edit therefore moved every word's timing and droppedoriginal, even opening an editor and leaving without typing (the editors save on blur). A Find & Replace of one word did the same to its whole sentence.They now compare the old and new word lists (longest common subsequence, exact text):
start,endandoriginal.The second commit (from
/simplify) changes no behaviour; 20,000 random edits compared against the first commit came out identical:retimeworks out the span and speaker itself, andeditSentenceis noweditParagraphon one sentence.countReplacementsgives the editor's live "N matches" count without building the replaced state. The count used to run a fullreplaceAllon every keystroke, which with this fix would also re-time every matching sentence. That cost about 45 ms per keystroke on a transcript joined into one 3,000-word sentence.Not in this PR:
original. The issue leaves that to the vocabulary underline step, which needs a prototype first.Tests
core/test/edit-keeps-words.test.tsholds the three tests agreed on #28, with literal values. All three failed onmainand pass now. Existing tests are unchanged.@core)Verified in the desktop app
tauri dev, macOS, with a test vocabulary ruleonline => on-line:on-linewords withoriginal: "online".A second run after
/simplifyreplaced "bed" → "sleep" (two matches in one sentence). The live count showed "2 matches". 42 of 44 words were identical in every field, and both replaced words kept their own times.The find fields were filled by a temporary dev-only hot-reload change, reverted before the commit. The app was driven in the background without keystrokes, and its Accessibility interface can't type into an inactive window. Inline sentence and paragraph edits open on double-click, so they weren't driven in the app; the unit and app tests cover them.