Skip to content

Extract createCellEditor function#14596

Open
seeM wants to merge 1 commit into
mainfrom
refactor/extract-create-cell-editor
Open

Extract createCellEditor function#14596
seeM wants to merge 1 commit into
mainfrom
refactor/extract-create-cell-editor

Conversation

@seeM

@seeM seeM commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Another step to simplify #14264, and maybe also a generally useful step.

The diff looks huge but it is just a cut and paste into a new function. Diff might look better if you hide whitespace changes.

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

Validation Steps

@:positron-notebooks @:web.

@seeM seeM requested a review from nstrayer June 30, 2026 20:52
@github-actions

Copy link
Copy Markdown

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:positron-notebooks @:web

readme  valid tags

@github-actions

Copy link
Copy Markdown

PETE's assessment 🧪

Verdict: 🟢 Adequate via existing coverage -- this is a pure cut-and-paste extraction of the editor-setup logic into createCellEditor, and the existing CellEditorMonacoWidget.vitest.tsx exercises every moved branch through the rendered widget.

What changed

  • The entire editor-setup body inside useCellEditorWidget's useEffect was extracted verbatim into a new top-level createCellEditor(...) function in CellEditorMonacoWidget.tsx; the hook now just calls it and wires up disposal. No behavior change -- the early-bailout guard, option building, focus/blur edit-mode logic, multi-select, and resize handlers all moved intact.

Tests in this PR

  • Unit (Vitest/Mocha) ✅ (existing coverage -- CellEditorMonacoWidget.vitest.tsx)
  • Extension host ✅ (not applicable)
  • E2E (Playwright) ✅ (not applicable -- refactor exercised by existing e2e under test/e2e/tests/notebooks-positron/)

Existing coverage

src/vs/workbench/contrib/positronNotebook/test/browser/notebookCells/CellEditorMonacoWidget.vitest.tsx renders CellEditorMonacoWidget (which calls useCellEditorWidget -> now createCellEditor) and asserts on the moved logic directly: editor attachment (attaches a code editor to the cell), contribution skip-list, Positron option overrides + live re-apply, dispose/detach on unmount, resize on layout and content-size change, edit-mode entry/exit on focus/blur including the overlay-guard and modifier-mousedown branches, and focus-restore paths. Because the function was moved without semantic changes, these tests fully pin the extracted code.

Suggested additions

None.

Suggested tags (optional)

None needed -- the PR body already carries @:positron-notebooks (a valid feature tag in test/e2e/infra/test-runner/test-tags.ts), so the notebook e2e suite under test/e2e/tests/notebooks-positron/ will run at PR time.


PETE (Positron Extreme Test Experiment) - LLM-based test-coverage advisor, in pilot. Triggers on PR open and on /recheck-tests comments. Wrong verdict? Comment /recheck-tests (or /rePETE) on this PR to re-run. Please share feedback on how PETE performed here.

@nstrayer nstrayer 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.

Good stuff. Again with the CI failures being suspiciously located but almost assuredly flakes.

Definitely a good candidate for extraction/abstraction.

@seeM seeM force-pushed the refactor/extract-create-cell-editor branch from ace1c43 to 6d4703e Compare July 4, 2026 08:17
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.

2 participants