Fix #13682: column paste anchors on the first selected row - #13685
Merged
Conversation
"Column > Paste from clipboard" and "Column > Insert text from subtitle" anchored on SelectedSubtitle, which is the moving end of a shift- or drag-selection (SelectGridRange deliberately makes the row the user stopped on the current one, so the edit box follows them). Selecting rows bottom-to-top therefore anchored on the top row and worked, while selecting the same rows top-to-bottom anchored on the bottom row: the paste started there and wrote over the lines below the selection instead of over the selection itself. Both commands now start at the topmost selected row - SE4's FirstSelectedIndex, which both of these code paths used. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merged
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.
Problem
Part 2 of #13682: Column > Paste from clipboard > Replace existing cells works when the rows are selected bottom-to-top, but pastes at the wrong place when the same rows are selected top-to-bottom.
ColumnPasteFromClipboardanchored onSubtitles.IndexOf(SelectedSubtitle).SelectedSubtitleis the moving end of a shift- or drag-selection —SelectGridRangedeliberately selectscurrentIndexfirst so the edit box and waveform follow the row the user stopped on. So:SE4 used
int index = FirstSelectedIndex;(4.0.16:src/ui/Forms/Main.cs:33434), which is direction-independent.Fix
New
MainViewModel.FirstSelectedSubtitleIndex— the topmost selected row, display-only reference rows excluded,-1when nothing editable is selected. It is SE4'sFirstSelectedIndex, built on the already-orderedSubtitleGridSelectedItems.Both column commands that write downwards from the selection now use it:
ColumnPasteFromClipboardColumnInsertTextFromSubtitle— same defect, and SE4 anchored it onFirstSelectedIndextoo (4.0.16:src/ui/Forms/Main.cs:33726)The
SelectedSubtitle == nullguards are gone: the existingidx < 0check already covers that, and it now also covers a selection consisting only of display-only reference rows, which the old guard let through.Verification
SubtitleGridSelectionOrderTestsshift-clicks in both directions through the real headless grid and asserts the anchor is the first selected row while the current row stays the row the user stopped onSelectedSubtitle, the downward case fails and the upward case passes — exactly the asymmetry reported in the issuedotnet build src/ui/UI.csproj— 0 warnings, 0 errorsdotnet test tests/UI/UITests.csproj— 2809 passed, 0 failedTwo earlier full-suite runs each had one failure (
WebVttStylePickerViewModelTests.CheckedStylesApplyAsCueClassesOnTheLineon the first), green in isolation and on re-run — the known parallel/shared-settings flake, unrelated to this code.Scope
This fixes only part 2 of #13682. Part 1 (restoring SE4's direct Ctrl+V overwrite of the selected lines) is untouched and needs its own change in
SubtitleGridCopyPasteHelper.Paste— which is also what open PR #13262 edits.Not addressed here either: the column paste silently truncates when the clipboard has more lines than there are rows below the anchor.
🤖 Generated with Claude Code