From 3c99f3f95092849b6b7761bf8f9f37ca45833f54 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Fri, 20 Feb 2026 20:59:26 -0500 Subject: [PATCH] fix --- attempt_1/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/attempt_1/main.c b/attempt_1/main.c index be1e628..3b03c4a 100644 --- a/attempt_1/main.c +++ b/attempt_1/main.c @@ -52,6 +52,7 @@ global FArena tape_arena; global FArena anno_arena; global U8 cursor_idx = 0; global U4 editor_mode = MODE_NAV; +global U4 mode_switch_now = false; // Executable Code Arena (The JIT) global FArena code_arena; @@ -278,7 +279,8 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) U1 c = u1_(wparam); // Skip control characters and the 'E' that triggered the mode - if (c < 32) break; + bool should_skip = c < 32 || (c == 'e' && mode_switch_now); + if (should_skip) { mode_switch_now = false; return 0; } if (tag == STag_Data) { // Hex input @@ -314,8 +316,11 @@ S8 win_proc(void* hwnd, U4 msg, U8 wparam, S8 lparam) case MS_WM_KEYDOWN: { if (wparam == 0x45 && editor_mode == MODE_NAV) { // 'E' editor_mode = MODE_EDIT; + mode_switch_now = true; ms_invalidate_rect(hwnd, nullptr, true); - return 0; // Consume the keypress so it doesn't trigger WM_CHAR + return 0; + // ~~Consume the keypress so it doesn't trigger WM_CHAR~~ + // NOTE(Ed): Still triggers WM_CHAR we need to track when we just entered edit mode and that must be consumed. } if (wparam == 0x1B && editor_mode == MODE_EDIT) { // ESC editor_mode = MODE_NAV;