From 10cf0da3d26b60575593d7896a9123d7ba7255bf Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 16 May 2026 20:49:23 +0200 Subject: [PATCH] fix(editor): capture-phase keydown + popup leak + cache warmup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses Critical #1 + Important #2/#3/#4 from the Task 9 code review. CRITICAL — Tab/Enter were stolen by CodeJar before the popup handler saw them. CodeJar registers its keydown listener during construction (line ~159), so it ran first in bubble order: Tab handler preventDefaulted and inserted 2 spaces, Enter handler preventDefaulted + stopPropagation'd (with leading indent), so the popup-accept either ran on corrupted state or never fired at all. Fix: register the popup listener with {capture: true} and call stopPropagation on the keys we own — that way capture phase fires before CodeJar's bubble listener and the key is fully consumed by the popup while it's visible. Normal typing (popup hidden) early-returns without stopPropagation, so CodeJar's tab-indent + enter-preserve-indent still work when there's no autocomplete to accept. IMPORTANT — destroy() leaked the popup