From 90560be614713e19c5a787dcabaa71d1b3132eb5 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 16 Feb 2026 18:10:35 -0700 Subject: [PATCH] Harden completion popup selection bounds --- editor/src/panels/EditorPanel.h | 4 ++++ progress.md | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/editor/src/panels/EditorPanel.h b/editor/src/panels/EditorPanel.h index 4032bc7..db1ef24 100644 --- a/editor/src/panels/EditorPanel.h +++ b/editor/src/panels/EditorPanel.h @@ -455,6 +455,7 @@ static void renderEditorPanel(EditorState& state) { bool popupHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup); int maxIndex = std::max(0, (int)filtered.size() - 1); + state.completionSelected = std::max(0, std::min(state.completionSelected, maxIndex)); if (ImGui::IsKeyPressed(ImGuiKey_DownArrow)) { state.completionSelected = std::min(state.completionSelected + 1, maxIndex); } @@ -500,6 +501,9 @@ static void renderEditorPanel(EditorState& state) { } if (accept && !filtered.empty()) { + state.completionSelected = + std::max(0, std::min(state.completionSelected, + (int)filtered.size() - 1)); const auto& item = filtered[state.completionSelected]; bool preferred = built.preferredNames.count(item.label) > 0; if (!preferred) { diff --git a/progress.md b/progress.md index 77282a3..a38ddef 100644 --- a/progress.md +++ b/progress.md @@ -5303,6 +5303,21 @@ dismiss, especially noticeable in text-mode editing. - `editor/src/EditorState.h` remains within header-size limit (`634` > `600`) — existing oversize file prior to this hotfix - `editor/src/panels/EditorPanel.h` remains within header-size limit (`850` > `600`) — existing oversize file prior to this hotfix +### Hotfix D: completion selection bounds hardening (stability) +**Status:** PASS (build stable) + +Hardened completion popup selection handling to prevent stale-selection indexing +when the candidate list shrinks between frames (e.g., while typing quickly and +confirming with Enter/Tab). + +**Files modified:** +- `editor/src/panels/EditorPanel.h` — clamped `completionSelected` before navigation and before selection accept + +**Verification run:** +- `cmake --build editor/build-native --target whetstone_editor` — PASS +- `step54_test` — PASS (10/10) regression coverage +- `step437_test` — PASS (8/8) regression coverage + # Roadmap Planning — Sprints 12-25+ ## Status: Planning Complete (Sprints 12-19 detailed, 20-25 in roadmap.md)