Fixed issue #1379: Redundant focused-node assignment ended node editing during keyboard navigation - #1387
Open
TetzkatLipHoka wants to merge 1 commit into
Open
Conversation
…d node editing during keyboard navigation Keyboard navigation sets the focused node twice: WMKeyDown moves the focus (which fires OnFocusChanged), then AddToSelection() assigns the - by now unchanged - focused node again. SetFocusedNode() always ran DoFocusNode(), which begins by ending a node edit. An edit started by the application inside OnFocusChanged was therefore ended again right away by that redundant assignment. With the mouse the event order differs, which is why the same handler worked there. Fix as suggested in the issue discussion: SetFocusedNode() exits early when the node is already focused, so the property setter has no side effects for a no-op assignment. DoFocusNode() itself is unchanged, its deliberate same-node handling (scroll into view) remains available to its direct callers. New regression test Tests/VTFocusChangedIssue1379Tests.pas covers the minimal contract (re-assigning the focused node keeps tsEditing) and the reported scenario (edit started in OnFocusChanged survives a VK_DOWN); both fail without the fix. Test suite: 2 pre-existing failures (TestCopyHTML1/2, also failing on unmodified master), no new failures. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #1379, implementing the check @joachimmarder suggested in the issue discussion ("I wonder if this check
if FocusedNode <> Nodeshould be part ofSetFocusedNode()") — yes, it works there, and this PR adds it with a regression test.Cause
Keyboard navigation sets the focused node twice:
WMKeyDownmoves the focus (which firesOnFocusChanged), thenAddToSelection()assigns the — by now unchanged — focused node again.SetFocusedNode()always ranDoFocusNode(), which begins by ending a node edit. An edit started by the application insideOnFocusChangedwas therefore immediately ended again by that redundant assignment. With the mouse the event order differs, which is why the same handler worked there.Fix
SetFocusedNode()exits early when the node is already focused, making the property setter free of side effects for a no-op assignment.DoFocusNode()itself is unchanged — its deliberate same-node handling (scroll into view, see the comment there) remains available to its direct callers.Verification
New regression test
Tests/VTFocusChangedIssue1379Tests.pas:tsEditing;OnFocusChangedsurvives a realVK_DOWNkey message, with the focus landing on the next node.Both tests fail without the fix. Full suite: no new failures (the two
TestCopyHTMLfailures also occur on unmodified master).🤖 Generated with Claude Code