Repository navigation
add null check in multiselect change handler - #14804
Merged
Merged
Conversation
gtritchie
reviewed
Jun 7, 2024
gtritchie
left a comment
Member
There was a problem hiding this comment.
What changed in Ace itself (diff too large to be seen, and wouldn't be useful anyway, I imagine)?
Collaborator
Author
|
The relevant change is here in the uncompressed file: https://github.com/rstudio/rstudio/pull/14804/files#diff-46ff06ba1e557a87e608075222ba4a4647b845bca02cc0c54862738089ef98d6R56118-R56121 So effectively, just a null check. |
Member
|
Oh duh, I didn't connect the dots between uncompressed and compressed ace.js. |
gtritchie
added a commit
that referenced
this pull request
Aug 4, 2026
* recover from corrupt ace multi-select editor state An exception escaping into Ace's multi-select machinery could leave a source editor permanently broken until the IDE was reloaded: mouse text selection dead, typed input silently discarded, multi-select mode impossible to exit, and editor commands landing in a previously focused tab. Ace's forEachSelection() and $moveLines() mutate selection state (temporary Selection object, silenced event registry, inVirtualSelectionMode, detached range list) and restore it with no exception protection, so a single mid-operation throw stranded that state permanently. This change fixes and hardens things on the RStudio side, leaving the bundled Ace behavior untouched so the defects can be reported upstream against stock Ace: - acesupport mixin (mixins/multi_select_guard) wraps forEachSelection and $moveLines with snapshot/restore semantics, so an aborting exception no longer strands the temporary selection, the silenced event registry, inVirtualSelectionMode, or a detached range list - AceEditorNative gains isMultiSelectStateCorrupt() and resetMultiSelectState(), extending the #13436 mouse-handler recovery to detect and repair leftover multi-select corruption; the check now also runs (deferred) when an editor regains focus - AceEditor.focus() updates the last-focused-editor tracking eagerly, so editor commands (e.g. insert pipe operator) cannot target a previously focused tab when the DOM focus event does not re-fire - applyChanges() and doSetCode() exit multi-select mode before driving command streams / replacing the document from async contexts - AceEditorNative.setHandler() callback is now $entry-wrapped, closing the one Ace-to-GWT callback that let GWT exceptions propagate raw into Ace's dispatch - removed a stray debugger; statement (shipped in both ace bundles since the #14804 null guard) that froze the IDE whenever devtools were open and the guard was reached The new Playwright spec injects a throwing document listener during a multi-cursor edit and asserts the editor survives; without the mixin it reproduces the corruption (stuck inVirtualSelectionMode, stranded temporary selection) deterministically. Addresses #13605. * document intentional inVirtualSelectionMode omission; log failed resets * address code review feedback for multi-select recovery - run only the multi-select corruption check from the focus path: the mouse-handler check misfires during an Alt+drag block selection, whose mousedown stops the event before the default capture handler runs (isMousePressed stays false while inVirtualSelectionMode is set) - have the corruption detector return a reason string so recovery logs say which corruption branch fired - resetMultiSelectState: restore session.$undoSelect (addRange clears it, and the bypassed $onRemoveRange is what normally restores it); log failures in the individual recovery steps; repair the selection marker count after a failed marker removal; and on a $onSingleSelect failure remove the 'exec' rerouting handler explicitly and keep the editor flagged as corrupt so the reset is retried - doSetCode/applyChanges: reset stranded corrupt state instead of calling the silently no-op exitMultiSelectMode; log when extra cursors are dropped - focus(): claim s_lastFocusedEditor only when focus actually landed, so focusing a hidden or detached editor can't steal command routing - multi_select_guard: describe each wrapped function's behavior separately, name the Ace internals the wrappers depend on, and log which stranded state a finally block repaired - e2e: prove fault injection with a window sentinel instead of exception routing; assert exact cursor and insertion counts; add coverage for the $moveLines guard, a healthy multi-cursor selection surviving tab switches, a detached-range-list corruption shape, and focus-path repair without a tab switch * add basic multi-select e2e tests Pin the everyday multi-select behaviors that the multi_select_guard wrappers must leave intact -- typing at keyboard-added cursors, single-step undo of a multi-cursor edit, splitIntoLines, and moving lines with multiple cursors -- driven through the real keyboard shortcuts. Addresses #13605. --------- Co-authored-by: Gary Ritchie <[email protected]>
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.
A potential fix for #13605.
Includes a
debuggercall just so we can request users attempt to capture this and provide more details if / when it occurs. (Thedebuggercall should be a no-op if no DevTools window is open.)