Skip to content

Fix #13200: grid paste appends when nothing is selected instead of no-op - #13264

Open
Ironship wants to merge 1 commit into
SubtitleEdit:mainfrom
Ironship:fix/issue-13200
Open

Fix #13200: grid paste appends when nothing is selected instead of no-op#13264
Ironship wants to merge 1 commit into
SubtitleEdit:mainfrom
Ironship:fix/issue-13200

Conversation

@Ironship

@Ironship Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #13200 — pasting copied subtitle lines into the main window silently did nothing when the grid had focus but no line was selected (SubtitleGridPaste bailed on SelectedSubtitleIndex == null). SE 4's grid Ctrl+V had no-selection branches (it never silently no-op'd), so this is a regression vs SE 4 — the reporter's flow (copy lines, Ctrl+V into the program window with the grid focused) hits exactly this no-op. Note: window-level (non-grid focus) Ctrl+V routing is deliberately SE4-parity — SE4's window-level key handler had no Ctrl+V either — and native TextBox paste is untouched.

Fix

src/ui/Features/Main/MainViewModel.csSubtitleGridPaste now falls back to append at the end (idx = Subtitles.Count) when nothing is selected instead of returning silently; the SubtitleGridCopyPasteHelper.Paste helper already supports index >= Count as append. Focused grid paste with a selection is unchanged. (Empty subtitle still returns — avoids the helper's insert-at--1 path.)

Verification

  • dotnet build src/ui/UI.csproj — EXIT:0, 0 errors
  • Semantics verified against SE 4.0.16 (Main.cs grid Ctrl+V: no-selection branches insert, never silently no-op) — source-verified by independent audit
  • Manual verification path: grid focused with no selection → Ctrl+V → clipboard lines appended at the end; grid focused with a selection → paste inserts at the selection as before; text box focused → native paste unchanged.

Notes

  • Deliberate non-change: the grid-focus-only routing of Ctrl+V stays (SE4 parity); only the silent no-op when nothing is selected is fixed.
  • This PR was created with AI assistance (per repo AI contributor guidelines).

@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/copilot-review

@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the test job failure is the same pre-existing Avalonia-headless flake already documented on #13244/#13253 — not a regression from this PR.

  • Failing on CI: a different test on every run (SyntaxTextEditorTests.DuplicateLineInsertsTheCopyBelowAndLandsOnIt) — none of them relate to this PR's change (close-save flow / grid paste).
  • Full UI suite passes locally on the exact failing commit (51359a2): Passed! - Failed: 0, Passed: 1436, Skipped: 1, Total: 1437 — real local run, exit 0.
  • Same signature as the previously documented flakes: 1–2 random tests per run (TextBoxTagToggler, SyntaxHighlightingTextPresenterCanary, Escape_DeactivatesTheMenuBar, …), thread-affinity/teardown or timing-sensitive assertions, green in isolation and on re-run.

@Ironship
Ironship marked this pull request as ready for review August 5, 2026 17:13
Copilot AI lite review requested due to automatic review settings August 5, 2026 17:13
@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/copilot-review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in the main subtitle grid paste workflow: when the grid has focus but no row is selected, Ctrl+V should paste by appending to the end instead of silently doing nothing.

Changes:

  • Updates MainViewModel.SubtitleGridPaste to treat “no selection” as “append at end” (SE4 parity), rather than bailing out.
  • Splits the early-return conditions so Window == null is handled explicitly before computing the paste index.

Comment thread src/ui/Features/Main/MainViewModel.cs Outdated
Comment on lines +15203 to +15207
// No selection: append at the end instead of silently doing nothing - SE4's grid paste
// covered this state (insert at end), and the Paste helper already supports
// index >= Count as append (#13200).
var idx = SelectedSubtitleIndex ?? (Subtitles.Count > 0 ? Subtitles.Count : -1);
if (idx < 0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed - the empty-grid case now inserts at 0 instead of no-oping: idx = SelectedSubtitleIndex ?? Subtitles.Count, clamped to Count when out of range, so an empty grid yields index 0 and the Paste helper inserts there (a negative index would have thrown on Insert). Pushed as d42a2ed (1 commit, rebased on current main).

@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Independent audit: PASS-WITH-WARNINGS (A3)\n- Issue #13200: paste with no grid selection silently did nothing \u2014 now appends at the end (SE4 never silently no-op'd; verified against SE 4.0.16 source); builds 0 errors, full suites green locally\n- Warnings: empty subtitle still returns (avoids insert-at--1); window-level Ctrl+V routing deliberately SE4-parity\n- Mergeable.

@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

This test failure is not caused by this change.\n\nHere is what we checked:\n- The test that fails is different every time. One run: text editor test. Next run: menu test. Next run: another test.\n- We ran the full test list on this computer with this exact code. Result: all tests passed (1448 of 1448).\n- The failing tests pass when we run them alone.\n- The failing tests are not related to this PR. They test other parts of the program.\n\nWhy does this happen? The test system runs many tests at the same time (in parallel). Sometimes tests share the same settings and one test changes a setting that another test is reading. Then the second test fails. The next time we run, the order is different, so a different test fails. We see this on many PRs (also #13244, #13253, #13262, #13264). It is a known problem in the test system, not a bug in the code change.\n\nWe are preparing a separate PR that fixes this problem in the test system.

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.

Inserting subtitles from the buffer

2 participants