Repository navigation
test(e2e): use activeEditor bridge in autocomplete actions - #17784
Merged
Merged
Conversation
getCompletionsInEditor was iterating document.querySelectorAll('.ace_editor')
and picking the first non-console match -- same bug ad175dc (#17775) fixed
for getEditorContent / openFile. On the failing tests the scan landed on a
stale empty source editor at DOM index 0 instead of the live editor at
index 1, so gotoLine + focus moved into the empty editor and Ctrl+Space
fired with nothing for the completer to anchor to.
Replace both the explicit-cursor and default-cursor branches with
window.rstudio.documents.activeEditor(), which maps through
SourceColumnManager.getActiveNativeEditor and reliably returns the
currently-active doc's editor. Also adds Session.getLength() to utils/ace.ts
so the default-cursor branch can stay typed.
Restores six autocomplete_extras.test.ts editor tests (pipe completions,
roxygen tags in .R/.Rmd/.qmd, already-used args pref, backtick-quoted
columns, _$ placeholder) and keeps the 14 autocomplete.test.ts tests
passing locally.
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
kevinushey
added a commit
that referenced
this pull request
May 27, 2026
empty-marker AceEditor was scanning .ace_editor DOM nodes and picking the first non-console match -- same stale-editor bug fixed in ad175dc (#17775) for openFile/getEditorContent and f84e454 (#17784) for autocomplete actions. on tests with a single open file the marker '' would trivially match, but the matched node could be a stale editor left in the DOM after a tab close rather than the live active editor. route empty marker through window.rstudio.documents.activeEditor() and keep the DOM-walk path for non-empty markers (still useful when a test needs a specific non-active tab).
4 tasks
kevinushey
added a commit
that referenced
this pull request
May 28, 2026
…tor (#17788) * test(e2e): pin desktop fixture window size to 1400x900 avoids dualwindowlayoutpanel auto-snapping the left column to maximize on the small (~1024x645) macos gh actions virtual display, which was hiding the source pane and breaking edit_suggestions tests. * test(e2e): route AceEditor('') through activeEditor bridge empty-marker AceEditor was scanning .ace_editor DOM nodes and picking the first non-console match -- same stale-editor bug fixed in ad175dc (#17775) for openFile/getEditorContent and f84e454 (#17784) for autocomplete actions. on tests with a single open file the marker '' would trivially match, but the matched node could be a stale editor left in the DOM after a tab close rather than the live active editor. route empty marker through window.rstudio.documents.activeEditor() and keep the DOM-walk path for non-empty markers (still useful when a test needs a specific non-active tab). * test(e2e): drop eval-based runOnEditor in AceEditor the previous shape stringified the user's callback via fn.toString() and reconstituted it in the browser with (0, eval)('(' + fnSource + ')'). that was the only way to ferry an arbitrary user function across the node->browser boundary through page.evaluate's single-arg form. replace it with page.evaluateHandle to resolve the editor once, then call handle.evaluate with the user's function natively (playwright serializes the function itself, no eval). overload run() so callers that pass no arg stay typed; callers that need multiple args wrap in an object. no behavior change for callers; the eval was a workaround the bridge has since obsoleted.
This was referenced Aug 4, 2026
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.
Summary
AutocompleteActions.getCompletionsInEditorwas iteratingdocument.querySelectorAll('.ace_editor')and focusing the first non-console match. On the failing autocomplete_extras tests the scan landed on a stale empty source editor at DOM index 0 instead of the live editor at index 1, sogotoLine+focusmoved into the empty editor and the subsequentCtrl+Spacefired with nothing for the completer to anchor to. This is the same class of bug ad175dc (test(e2e): expose active ace editor via automation bridge #17775) fixed forgetEditorContent/openFile.window.rstudio.documents.activeEditor(), which maps throughSourceColumnManager.getActiveNativeEditorand reliably returns the active doc's editor.Session.getLength()toutils/ace.tsso the default-cursor branch can stay typed.Diagnostic output from a failing run before the fix (cursor placed at row 0 / column 0 in an empty editor, while the actual active editor held the test content):
Test plan
npm run typechecknpm run test:desktop-dev -- autocomplete_extras-- 11/11 passednpm run test:desktop-dev -- tests/panes/misc/autocomplete.test.ts-- 14/14 passed