Skip to content

Fix #12195: split line at cursor applies the continuation style (ellipses) - #13266

Merged
niksedk merged 1 commit into
SubtitleEdit:mainfrom
Ironship:fix/issue-12195-ellipses
Aug 6, 2026
Merged

Fix #12195: split line at cursor applies the continuation style (ellipses)#13266
niksedk merged 1 commit into
SubtitleEdit:mainfrom
Ironship:fix/issue-12195-ellipses

Conversation

@Ironship

@Ironship Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #12195 (point 1) — "Split line at cursor" does a clean cut in SE 5.1.0, while SE 4 appended the continuation marker per the configured continuation style (the reporter's "Ellipses (right only)" = OnlyTrailingEllipsis). The SplitManager never applied the continuation style.

Fix

src/ui/Logic/ISplitManager.cs — after the text split, the configured ContinuationStyle is applied to the two halves via the existing ContinuationUtilities (same code path SE 4 used): a trailing ellipsis on the first line and a leading marker on the second for leading styles. Markers are applied only when both split halves contain text; None and an empty second half leave the clean cut unchanged.

Verification

  • dotnet build src/ui/UI.csproj — EXIT:0, 0 errors
  • Permanent Split_WithTextIndex_AppliesConfiguredContinuationStyle regression test: ContinuationStyle=OnlyTrailingEllipsis, split "Hello world foo bar" at cursor → first half Hello world foo… (U+2026), second bar; proven RED on the parent commit and GREEN on this fix
  • Empty-second-half regression: RED before the guard (Hello…), GREEN after it (Hello + empty second half)
  • SplitManagerTests: 30/30 passed
  • Full local UI suite: 1453 passed, 1 skipped, 0 failed
  • Manual verification path: right-click → Split line at cursor with continuation style "Ellipsis (trailing only)" → first line ends with an ellipsis; with "None" → clean cut as before.

Notes

  • Deliberate non-change: the issue's point 2 (grid paste overwriting selected lines) is a separate behavior — not touched here.
  • 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/#13262/#13264 — not a regression from this PR.

  • Failing on CI: UITests.Controls.SyntaxTextEditorTests.DeleteWordLeftAndRightRemoveOneWord — unrelated to this PR's change (SplitManager continuation style).
  • Full UI suite passes locally on the exact failing commit (9acb7a8): Passed! - Failed: 0, Passed: 1442, Skipped: 1, Total: 1443 — real local run, exit 0, including the SyntaxTextEditor tests.
  • Same signature as the previously documented flakes: 1–2 random tests per run (SyntaxTextEditor victims rotate: DeleteLineOnTheOnlyLine, ShiftArrowSelects, DuplicateLine, now DeleteWordLeftAndRight), thread-affinity/teardown or timing-sensitive assertions, green in isolation and on re-run.

@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Update — the flake now also hits the new upstream SplitManagerTests (5 tests in one run). Decisive evidence this is scheduling-order flakiness, not this PR: on the exact same commit (9acb7a8) with the exact same build (--no-build), run 1 failed those 5 tests and run 2 passed 1448/1448 — the code is byte-identical between the two runs; only xUnit's parallel class scheduling varied. The tests only assert exact split texts and no test in the suite touches the ContinuationStyle setting this PR reads (default None → the added block is inert in the test suite). Same signature as the earlier documented victims (MainMenuKeyboardActivation, SyntaxTextEditor).

@Ironship
Ironship marked this pull request as ready for review August 5, 2026 17:23
@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/copilot-review

Copilot AI lite review requested due to automatic review settings August 5, 2026 17:23
@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Audit follow-up: TryParse hardening applied (90d844a) — corrupt/legacy config values now fall back to the clean cut instead of throwing. The 5 SplitManagerTests failures in the audit run were traced to the auditor's own throwaway probe leaking static settings (probe deleted); the PR is not responsible.

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

This PR fixes regression #12195 by making “Split line at cursor” apply the configured continuation style (e.g., trailing ellipsis) after splitting, restoring Subtitle Edit 4 behavior in the v5 UI split flow.

Changes:

  • Apply ContinuationStyle to the split halves via ContinuationUtilities after splitting the subtitle text.
  • Add ContinuationStyle enum import to enable parsing the stored continuation-style setting.

Comment on lines +139 to +140
if (ContinuationUtilities.ShouldAddSuffix(subtitle.Text, continuationProfile))
{

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.

Checked - both continuation helpers already guard empty input: AddPrefixIfNeeded returns the original text when the sanitized halves are both empty (ContinuationUtilities.cs:453-456), and AddSuffixIfNeeded has the same guard (:354-357). An empty second half therefore never gets a marker - the split path is safe as-is. No code change needed.

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.

You were right. My first reply checked only the helper used for the empty second half. It missed that the non-empty first half still received a trailing ellipsis. Fixed in 62a4daa: continuation markers are now applied only when both split halves contain text. Added a permanent RED/GREEN regression test. Fresh checks: SplitManagerTests 30/30, full local UI suite 1453 passed / 1 skipped / 0 failed, UI build EXIT:0.

@Ironship

Ironship commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Independent audit: PASS-WITH-WARNINGS (A3, audit follow-up applied)\n- Issue #12195 point 1: split line at cursor ignored the continuation style \u2014 SplitManager now applies ContinuationUtilities (SE4 parity); throwaway probe: 'Hello world foo bar' \u2192 'Hello world foo\u2026'/'bar' with OnlyTrailingEllipsis\n- Audit follow-up (90d844a): Enum.TryParse hardening (corrupt/legacy config falls back to clean cut instead of throwing); the 5 SplitManagerTests failures in the audit run were traced to the auditor's own probe leaking static settings (deleted) \u2014 not this PR\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.

@Ironship
Ironship force-pushed the fix/issue-12195-ellipses branch 3 times, most recently from 51539ff to 0625608 Compare August 6, 2026 08:11
@Ironship

Ironship commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

FINAL AUDIT #13266 for issue #12195 point 1: PASS\n\nFresh head: 0625608; one Ironship commit; two focused files. The continuation block is reachable for every SplitManager split path, is inert for None or corrupt/legacy enum values, reuses existing ContinuationUtilities, and runs before FixTags/timing calculations. No unrelated behavior or dead code found.\n\nAudit follow-up: added one permanent regression test with global setting restored in finally. It FAILS on the parent commit and PASSES on this fix; all SplitManagerTests pass 29/29 and UI build exits 0.

@Ironship
Ironship force-pushed the fix/issue-12195-ellipses branch from 0625608 to 62a4daa Compare August 6, 2026 09:26

@niksedk niksedk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approve

Checked the thing that decides whether this is safe to ship: SeGeneral.cs:141 sets ContinuationStyle = ContinuationStyle.None.ToString() as the default, and the new block is gated on continuationStyle != ContinuationStyle.None. So for anyone who has not deliberately chosen a continuation style this is a no-op, and for anyone who has, it restores the SE4 behaviour they configured. That is the right shape for #12195.

The guards are complete: both halves must be non-empty, the setting must parse, and ShouldAddSuffix still has the final say — so a line already ending in a suffix, or a split that leaves nothing on the right, is untouched. Split_WithoutSecondHalf_DoesNotAddContinuationMarker covers that second case explicitly.

Note for later, not a blocker: only the trailing-ellipsis path is covered by a test. The leading-marker branch (AddPrefixIfNeeded, used by LeadingTrailingEllipsis — which several built-in profiles select) is exercised by no test. Worth adding, since profile users will hit it.

Merging.

@niksedk
niksedk merged commit 4deb0c3 into SubtitleEdit:main Aug 6, 2026
1 check passed
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.

Questions about 'Split line' behavior and pasting onto the grid in v5

3 participants