Skip to content

fix: a command line whose Enter ends in a notice gives the Field focus back (#90) - #94

Merged
Kyu-seok merged 2 commits into
mainfrom
issue-90
Nov 22, 2026
Merged

Kyu-seok merged 2 commits into
mainfrom
issue-90

Conversation

@Kyu-seok

Copy link
Copy Markdown
Owner

Summary

A command line whose Enter ends in a notice (a search that finds nothing, an unknown ex command, :w, a failed :s or :set, :registers) left focus on <body>: the Status Line showed the notice and the next key reached no Field. The adapter hands focus back only when the prompt contains document.activeElement, and the prompt's input is in the Status Line's shadow root, where that reads as the host.

 Enter in the prompt
   the command runs → showConfirm → cm.openNotification(notice)
+    Mirror.focusAfterNotice (wraps the instance's openNotification)
+      hadFocus = the dialog about to be replaced contains its own tree's activeElement
       adapter showDialog(notice)
         oldDialog.contains(document.activeElement)?   # false: it is the shadow host
         the notice replaces the prompt                 # focus drops to <body>
+      hadFocus → cm.focus() → Session.focusForEngine() # the marked focus of #88: the Cursor stays
   input.blur(); close()                                # close skips its focus: a notice is showing

:wq and :x still end blurred behind their notice. They now blur a Field the notice has just focused, as :q does; before, the Field was already blurred.

docs/engine-seams.md "Focus" and "Leaving a contenteditable Field" say what is true now; the two Chromium facts are pinned in tests/unit/chromium-facts.test.ts, "Focus".

Evidence

  • Before: npm run red-on-main on the changed spec files → "every file is red on main": the 40 tests that pin the fix fail there, on the missing focus.
    After: npm run check passes: 572 unit tests, 262 e2e, 0 flaky. npm run test:e2e:editors: 295 passed, 0 flaky.
textarea, Single-line Field, contenteditable:
  w, then /zzz ?zzz :bogus :w :s/zzz/y/ ":set nosuchoption" :registers + Enter
      → the notice shows, the Field is document.activeElement, x deletes the second word's first character
  w v e :bogus Enter x      → focused; the engine left Visual, x deletes the selection's last character
  w i|R Ctrl-o :bogus Enter Z → focused; Z is inserted at the Cursor
contenteditable in an open shadow root; ProseMirror, Slate, Quill, Lexical:
  w, then /zzz or :w + Enter, x → the second word's first character is deleted
guards for the leave path (green on main too):
  :wq and :x on a Single-line Field, :x on a contenteditable, :wq on each rich editor
      → the Field ends blurred, a caret for its selection, the notice shows and then the bar hides

Merge Danger

Door: two-way

Reverting the two commits restores the old behaviour. Nothing is stored or migrated.

Blast Radius: every notice

  • The wrapper sees every notice the engine or VimText opens. It moves focus only when the dialog being replaced held focus, so a notice shown with no prompt open changes nothing.
  • One of VimText's own notices arriving while the person is still typing in the prompt (a clipboard read that failed, an edit the page refused) replaces the prompt as before, and the Field now has focus after it: the keys typed next go to the Field instead of nowhere. No test covers this.
  • Engine semantics the tests record, not change: Ctrl-o from Replace mode comes back in Insert; a notice-ending ex command from Visual mode leaves Normal mode.
  • Not asserted: that the :registers listing stays after the next key.

Closes #90

🤖 Generated with Claude Code

Kyu-seok and others added 2 commits November 21, 2026 00:39
…s back (#90)

The adapter's showDialog hands focus back, when a notice replaces the prompt,
only if the prompt contains document.activeElement. The prompt's input is in
the Status Line's shadow root, where that reads as the host, so a search that
finds nothing, an unknown ex command, :w, a failed :s or :set and :registers
left focus on <body> and the next key reached no Field.

The mirror wraps the instance's openNotification: it makes the same check in
the prompt's own tree before the notice replaces the prompt, and calls
cm.focus() after (the Session's marked focus, so the Cursor stays, #88).
:wq and :x still end blurred behind their notice; they now blur a focused
host, as :q does.

Closes #90

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… every Field type, and one helper for the command line's steps

- Ctrl-o then a notice-ending command line from Insert and from Replace mode
  is covered on the three Field types (red on main). The engine comes back in
  Insert from both, with or without a command line; the test says so.
- :wq and :x now blur a Field the notice has just focused, so that path is
  pinned where it was not: :wq and :x on a Single-line Field, :x on a
  contenteditable, :wq on each rich editor. These pass on main too: they guard
  the outcome #65 set, they are not this fix's regression tests.
- The steps every notice test repeated are `submitForNotice` in the e2e
  helpers; the rich-editor tests assert the host's focus, which their comment
  claimed.
- The mirror's wrapper names what it reads (`replaced`, `hadFocus`), and the
  blurred-host branch of ContentEditableField.blur names the case it is left
  for.

Refs #90

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Kyu-seok
Kyu-seok merged commit f1ad77f into main Nov 22, 2026
1 check passed
@Kyu-seok
Kyu-seok deleted the issue-90 branch November 22, 2026 05:31
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.

A command line whose Enter ends in a notice leaves no Field focused (:w, a search that finds nothing, an unknown ex command, :registers)

1 participant