[gtksourceview] vim: ignore numerics when mods are set
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] vim: ignore numerics when mods are set
- Date: Tue, 7 Dec 2021 06:27:05 +0000 (UTC)
commit 8ecc7bdf99c57a37356424cf327a161a4835d1af
Author: Christian Hergert <chergert redhat com>
Date: Mon Dec 6 22:25:30 2021 -0800
vim: ignore numerics when mods are set
This can help with common keybindings.
gtksourceview/vim/gtksourcevimnormal.c | 3 ++-
gtksourceview/vim/gtksourcevimvisual.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/vim/gtksourcevimnormal.c b/gtksourceview/vim/gtksourcevimnormal.c
index 8d2ab835..632b4fd6 100644
--- a/gtksourceview/vim/gtksourcevimnormal.c
+++ b/gtksourceview/vim/gtksourcevimnormal.c
@@ -1217,7 +1217,8 @@ key_handler_initial (GtkSourceVimNormal *self,
case GDK_KEY_7: case GDK_KEY_KP_7:
case GDK_KEY_8: case GDK_KEY_KP_8:
case GDK_KEY_9: case GDK_KEY_KP_9:
- if (self->has_count == FALSE)
+ /* ignore if mods set as that is a common keybinding */
+ if (self->has_count == FALSE && mods == 0)
self->handler = key_handler_count;
break;
diff --git a/gtksourceview/vim/gtksourcevimvisual.c b/gtksourceview/vim/gtksourcevimvisual.c
index ca9611dc..6d3765fb 100644
--- a/gtksourceview/vim/gtksourcevimvisual.c
+++ b/gtksourceview/vim/gtksourcevimvisual.c
@@ -563,11 +563,17 @@ key_handler_initial (GtkSourceVimVisual *self,
case GDK_KEY_7: case GDK_KEY_KP_7:
case GDK_KEY_8: case GDK_KEY_KP_8:
case GDK_KEY_9: case GDK_KEY_KP_9:
+ /* ignore if mods set as that is a common keybinding */
+ if (self->count == 0 && mods != 0)
+ return FALSE;
+
self->count *= 10;
+
if (keyval >= GDK_KEY_0 && keyval <= GDK_KEY_9)
self->count += keyval - GDK_KEY_0;
else if (keyval >= GDK_KEY_KP_0 && keyval <= GDK_KEY_KP_9)
self->count += keyval - GDK_KEY_KP_0;
+
return TRUE;
case GDK_KEY_z:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]