summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2023-01-16 13:36:25 -0700
committercflip <cflip@cflip.net>2023-01-16 13:36:25 -0700
commit58d38d02b215f2e4829ccdc399df8d59bb6cb140 (patch)
treee59bd669d2381ce320dc952752d31e0606347b5a /window.c
parent617db1d87703e929390a3ea04d189a25c4aaa026 (diff)
Ignore first keypress after entering insert mode
This fixes the problem where the key used to enter insert mode ('i' for example) would also be typed into the document.
Diffstat (limited to 'window.c')
-rw-r--r--window.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/window.c b/window.c
index 3ffd748..ee97ed9 100644
--- a/window.c
+++ b/window.c
@@ -49,6 +49,14 @@ int window_handle_event(struct editor_state *editor)
case SDL_TEXTINPUT:
if (editor->mode == EDITOR_MODE_NORMAL)
break;
+ /*
+ * Ignore the first letter after entering insert mode, because it
+ * usually is just 'i'.
+ */
+ if (editor->pressed_insert_key) {
+ editor->pressed_insert_key = 0;
+ break;
+ }
editor_insert_char(editor, *e.text.text);
break;
}