Visual Studio Code, rebuilt in Rust
Rust
fix(notebook): a late webview did-focus no longer steals the keyboard from the list
rokarturdb096f9a3aff
diff --git a/native/crates/app/src/webview/linux.rs b/native/crates/app/src/webview/linux.rsindex 963496b67ae..5437a69a247 100644--- a/native/crates/app/src/webview/linux.rs+++ b/native/crates/app/src/webview/linux.rs@@ -61,6 +61,10 @@ impl Webview {match self.never {}}+ pub fn has_keyboard(&self) -> bool {+ match self.never {}+ }+pub fn show_find(&self, _styles: &Value, _icons: [String; 3]) {match self.never {}}diff --git a/native/crates/app/src/webview/macos.rs b/native/crates/app/src/webview/macos.rsindex b687e943a19..90b59b7b98b 100644--- a/native/crates/app/src/webview/macos.rs+++ b/native/crates/app/src/webview/macos.rs@@ -149,6 +149,11 @@ impl Webview {}}+ /// Whether the view or one of its subviews is the window's first responder.+ pub fn has_keyboard(&self) -> bool {+ self.view.window().is_some_and(|window| self.is_first_responder(&window))+ }+fn is_first_responder(&self, window: &NSWindow) -> bool {// WKWebView hands first responder to an internal subview while editing; any descendant counts.let Some(responder) = window.firstResponder() else { return false };diff --git a/native/crates/app/src/workbench/notebook_editor.rs b/native/crates/app/src/workbench/notebook_editor.rsindex 9827d458af8..f86740ab19d 100644--- a/native/crates/app/src/workbench/notebook_editor.rs+++ b/native/crates/app/src/workbench/notebook_editor.rs@@ -416,8 +416,12 @@ impl Workbench {let Some(back_layer) = self.notebook_views.views.get_mut(&tab).and_then(|view| view.webview.as_mut()) else { return };match channel {"webview-ready" => back_layer.webview.did_become_ready(),+ // The iframe's focus event can arrive after a "clickMarkupCell" of the same press gave the list the keyboard:+ // upstream's list keeps the DOM focus then, so only a webview still holding the keyboard blurs the workbench."did-focus" => {- back_layer.webview.take_keyboard();+ if !back_layer.webview.has_keyboard() {+ return;+ }window.blur(cx);}"did-keydown" => {diff --git a/port/ledger.md b/port/ledger.mdindex e3f770f6188..69d4ec2a790 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -595,7 +595,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| extension/html | built-in extension | M7 | verified | | grammar: cargo test -p app syntax::tests::colorize_fixtures_match_the_reference (its colorize-tests fixtures, scopes and 10 default theme colors) || extension/html-language-features | built-in extension | M13 | verified | | its language server runs in the extension host: ui-pair `<di` in a.html gives the same tag completions, breadcrumbs and status bar (port/results/language-features.md, HTML and CSS) || extension/ini | built-in extension | M7 | verified | | grammar: cargo test -p app syntax::tests::colorize_fixtures_match_the_reference (its colorize-tests fixtures, scopes and 10 default theme colors) |-| extension/ipynb | built-in extension | M17 | ported | [3 S] notebook_editor: a click on a markdown preview then Down left the focus on Cell 1 in 1 of 2 runs of ui-pair m17/notebook-output-toolbar.json `focus-bars` (the reference moves to Cell 2) | ui-pairs m17/notebook-open, notebook-keys-outline, notebook-output-toolbar, notebook-toolbars and notebook-cli at 8f138e76960 match the reference: the differences of notes m17 (open, keys and outline, output toolbar, command line JSON) are gone (port/notes.md milestone 17, views audit). verified (session m17d): api-tests `MOCHA_GREP="Notebook|ipynb|Interactive Window|Ensure tabs getter"` 41/10/0 three runs in a row at 499a612a62f (the 10 pending are upstream skips; `Ensure tabs getter` failed in 2 of 3 runs before the exthost fix that holds workbench answers until the queue before them is sent) (ipynb suite: the reference skips the same); ui-pairs m17 notebook-open, notebook-restore (hot exit through the ipynb serializer) match; `contributes.notebooks` editors in the editor resolver (custom_editors.rs, notebookServiceImpl.ts priorities): a `.ipynb` opens from the Explorer as a notebook; port/tools/ui-pair port/fixtures/ui-pair/m17/notebook-open.json on port/fixtures/notebooks/sample.ipynb shows the markdown preview, code cells and outputs as the reference (port/notes.md lists the differences left) |+| extension/ipynb | built-in extension | M17 | ported | [3 S] notebook_editor list scrollbar: after a click on the markdown preview with the pointer resting over the list the port shows the cell list's vertical scrollbar, the reference none (ui-pair m17/notebook-output-toolbar.json `focus-bars`) | a webview "did-focus" arriving after the same press's "clickMarkupCell" no longer takes the keyboard back from the list (notebook_editor.rs, webview has_keyboard): with a stale did-focus re-dispatched after every click 3 of 3 runs ended on Cell 1 before the fix, Cell 2 after; 6 of 6 plain runs of the click then Down end on Cell 2 of 4; ui-pair m17/notebook-output-toolbar.json `focus-bars` matches the reference; ui-pairs m17/notebook-open, notebook-keys-outline, notebook-output-toolbar, notebook-toolbars and notebook-cli at 8f138e76960 match the reference: the differences of notes m17 (open, keys and outline, output toolbar, command line JSON) are gone (port/notes.md milestone 17, views audit). verified (session m17d): api-tests `MOCHA_GREP="Notebook|ipynb|Interactive Window|Ensure tabs getter"` 41/10/0 three runs in a row at 499a612a62f (the 10 pending are upstream skips; `Ensure tabs getter` failed in 2 of 3 runs before the exthost fix that holds workbench answers until the queue before them is sent) (ipynb suite: the reference skips the same); ui-pairs m17 notebook-open, notebook-restore (hot exit through the ipynb serializer) match; `contributes.notebooks` editors in the editor resolver (custom_editors.rs, notebookServiceImpl.ts priorities): a `.ipynb` opens from the Explorer as a notebook; port/tools/ui-pair port/fixtures/ui-pair/m17/notebook-open.json on port/fixtures/notebooks/sample.ipynb shows the markdown preview, code cells and outputs as the reference (port/notes.md lists the differences left) || extension/jake | built-in extension | M15 | verified | | runs unchanged in the host; ui-pair with port/fixtures/task-runners (`jake.autoDetect` on): its tasks listed under Run Task and run in a task terminal as in the reference (port/results/terminal.md, grunt, gulp, jake) || extension/java | built-in extension | M7 | verified | | grammar: cargo test -p app syntax::tests::colorize_fixtures_match_the_reference (its colorize-tests fixtures, scopes and 10 default theme colors) || extension/javascript | built-in extension | M7 | verified | | grammar: cargo test -p app syntax::tests::colorize_fixtures_match_the_reference (its colorize-tests fixtures, scopes and 10 default theme colors) |