Skip to content

LT-22679: Send Copy and Paste to the Sandbox in Analyze - #1258

Merged
thejambi merged 2 commits into
mainfrom
LT-22679-word-gloss-copy-paste
Nov 24, 2026
Merged

thejambi merged 2 commits into
mainfrom
LT-22679-word-gloss-copy-paste

Conversation

@thejambi

@thejambi thejambi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

In Texts > Analyze, Edit > Copy, Edit > Paste, Ctrl+C and Ctrl+V now act on the Word Gloss (or other field) being edited in the focus box. Until now they often acted on the interlinear text behind it instead: Copy put the wrong text on the clipboard, and the menu items were grayed out or enabled depending on what was selected in the text rather than in the gloss.

Reviewer notes

Root cause. FwXWindow sends Copy and Paste to the root site ActiveViewHelper reports, and ActiveViewHelper records whichever root site raised GotFocus last. InterlinDocForAnalysis.OnGotFocus moved focus into the focus box before calling base.OnGotFocus. The Sandbox raised GotFocus first and was recorded; then the text's own GotFocus ran late and overwrote it, although the text no longer had focus. That late SimpleRootSite.OnGotFocus also pointed the global focused root site, the selection activation and the keyboard at the text.

Fix. Call base.OnGotFocus first, then hand focus to the focus box, the order BrowseViewer and ConstituentChart already use. InterlinDocForAnalysis was the only OnGotFocus override that handed focus on before raising its own.

Deliberate rules.

  • The text's selection and keyboard are still switched on for a moment before focus moves to the Sandbox. Those calls ran before this change too, only last; Win32 sends the text its kill-focus before the Sandbox gets set-focus, so the text deactivates and the Sandbox ends up as the focused root site.
  • Not chosen: making ActiveViewHelper.ViewGotFocus ignore a sender that no longer has focus. It would cover any other view with the same ordering, but it changes code every main window shares and would leave the global focused root site and keyboard on the text.

Tests. New FocusBoxControllerTests.OnGotFocus_FocusBoxInstalled_SandboxIsActiveView shows a form holding an interlinear text with a real Sandbox (not a mock) and an ActiveViewHelper, focuses another control, then focuses the text and expects the Sandbox to be reported. It failed before the fix (reported the text) and passes after. It needs real window focus; on a runner without an interactive desktop its Assume makes it inconclusive rather than failing. The test focus box owns its own Mediator and PropertyTable because the Sandbox writes to them while being disposed, after the text has disposed its own. The IText, RootSites and Discourse test sets pass (661 passed, 2 skipped, both already marked to skip).

Manual tests (done). In FLEx, Texts > Analyze: selected a word's Word Gloss, copied it with Ctrl+C and with Edit > Copy, clicked another word, and pasted into its gloss with Ctrl+V and with Edit > Paste. The gloss text was pasted each time, the Edit menu items were enabled while the gloss had a selection, and the clipboard held the gloss rather than text from the interlinear view. Repeated across several words.

🤖 Generated with Claude Code


This change is Reviewable

In Texts > Analyze, Edit > Copy, Edit > Paste, Ctrl+C and Ctrl+V
often acted on the interlinear text instead of the word gloss being
edited. Copy put the wrong text on the clipboard, and the menu items
were grayed out depending on the text's selection.

The main window sends these commands to the view ActiveViewHelper
reports. InterlinDocForAnalysis.OnGotFocus moved focus into the
focus box before raising its own GotFocus, so the Sandbox was
recorded first and then overwritten by the text, which no longer
had focus. The same late call also re-activated the text's
selection and keyboard.

Raise GotFocus before handing focus on, as BrowseViewer and
ConstituentChart already do. The new test hosts a real Sandbox in
a shown form and checks ActiveViewHelper reports it after the text
is focused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

NUnit Tests

    1 files  ± 0      1 suites  ±0   9m 20s ⏱️ - 6m 4s
7 364 tests +54  7 285 ✅ +54  79 💤 ±0  0 ❌ ±0 
7 373 runs  +54  7 294 ✅ +54  79 💤 ±0  0 ❌ ±0 

Results for commit 5a660a7. ± Comparison against base commit d6b31fd.

♻️ This comment has been updated with latest results.

@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.48%. Comparing base (fae5de0) to head (5a660a7).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1258      +/-   ##
==========================================
+ Coverage   40.34%   40.48%   +0.14%     
==========================================
  Files        1597     1598       +1     
  Lines      360082   360584     +502     
  Branches    42148    42191      +43     
==========================================
+ Hits       145282   145995     +713     
+ Misses     185121   184924     -197     
+ Partials    29679    29665      -14     
Files with missing lines Coverage Δ
Src/LexText/Interlinear/InterlinDocForAnalysis.cs 18.43% <100.00%> (+1.38%) ⬆️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The order now matches BrowseViewer and ConstituentChart, and the
regression test pins it, so the comment adds nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thejambi
thejambi marked this pull request as ready for review November 23, 2026 23:56

@mark-sil mark-sil 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.

LGTM

@thejambi
thejambi merged commit 44b30f5 into main Nov 24, 2026
8 of 9 checks passed
@thejambi
thejambi deleted the LT-22679-word-gloss-copy-paste branch November 24, 2026 13:29
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.

3 participants