[geany/geany-osx] 5a071e: Add latest vimode fixes
Jiří Techet
git-noreply at xxxxx
Wed Nov 24 15:36:27 UTC 2021
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Wed, 24 Nov 2021 15:36:27 UTC
Commit: 5a071ebc873dec9b34888a60deb1c24e5ce50ca3
https://github.com/geany/geany-osx/commit/5a071ebc873dec9b34888a60deb1c24e5ce50ca3
Log Message:
-----------
Add latest vimode fixes
Modified Paths:
--------------
geany.modules
geany_patches/03-geany_plugins_vimode_eol_eof_fix.patch
geany_patches/04-geany_plugins_vimode_caret_fix.patch
geany_patches/05-geany_plugins_vimode_numlock_fix.patch
Modified: geany.modules
6 lines changed, 6 insertions(+), 0 deletions(-)
===================================================================
@@ -146,6 +146,9 @@
<patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/01-geany_plugins_spellcheck_relocation.patch" strip="1" />
<!-- TODO: remove once merged upstream -->
<patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/02-geany_plugins_vimode_height.patch" strip="1" />
+ <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/03-geany_plugins_vimode_eol_eof_fix.patch" strip="1" />
+ <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/04-geany_plugins_vimode_caret_fix.patch" strip="1" />
+ <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/05-geany_plugins_vimode_numlock_fix.patch" strip="1" />
</branch>
<dependencies>
<dep package="geany-git" />
@@ -163,6 +166,9 @@
<patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/01-geany_plugins_spellcheck_relocation.patch" strip="1" />
<!-- TODO: remove once merged upstream -->
<patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/02-geany_plugins_vimode_height.patch" strip="1" />
+ <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/03-geany_plugins_vimode_eol_eof_fix.patch" strip="1" />
+ <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/04-geany_plugins_vimode_caret_fix.patch" strip="1" />
+ <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/05-geany_plugins_vimode_numlock_fix.patch" strip="1" />
</branch>
<dependencies>
<dep package="geany-release" />
Modified: geany_patches/03-geany_plugins_vimode_eol_eof_fix.patch
54 lines changed, 54 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,54 @@
+From c1e848aca29ef9b673b1378da10cb8e625668779 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= <techet at gmail.com>
+Date: Tue, 23 Nov 2021 23:17:49 +0100
+Subject: [PATCH] vimode: fix detection of missing EOL at EOF
+
+The previous code was incorrect. The new code just
+
+1. Goes to the last position in document
+2. Goes one position before that
+3. Checks if the lines corresponding to (1) and (2) are identical - in this
+case the NL is missing at EOF
+---
+ vimode/src/cmds/edit.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/vimode/src/cmds/edit.c b/vimode/src/cmds/edit.c
+index d23b8e82..8e687257 100644
+--- a/vimode/src/cmds/edit.c
++++ b/vimode/src/cmds/edit.c
+@@ -84,12 +84,13 @@ void cmd_clear_right(CmdContext *c, CmdParams *p)
+ static gboolean insert_eof_nl_if_missing(CmdParams *p)
+ {
+ gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0);
+- gint last_line = SSM(p->sci, SCI_GETLINECOUNT, 0, 0);
+- gint line_start_pos = SSM(p->sci, SCI_POSITIONFROMLINE, last_line, 0);
+- gint line_end_pos = SSM(p->sci, SCI_GETLINEENDPOSITION, last_line, 0);
++ gint eof_pos = SSM(p->sci, SCI_GETLENGTH, 0, 0);
++ gint eof_line_num = SSM(p->sci, SCI_LINEFROMPOSITION, eof_pos, 0);
++ gint before_eof = PREV(p->sci, eof_pos);
++ gint before_eof_line_num = SSM(p->sci, SCI_LINEFROMPOSITION, before_eof, 0);
+
+- if (line_start_pos == line_end_pos) {
+- SET_POS(p->sci, line_end_pos, FALSE);
++ if (eof_line_num == before_eof_line_num) {
++ SET_POS(p->sci, eof_pos, FALSE);
+ SSM(p->sci, SCI_NEWLINE, 0, 0);
+ SET_POS(p->sci, pos, FALSE);
+ return TRUE;
+@@ -101,10 +102,9 @@ static gboolean insert_eof_nl_if_missing(CmdParams *p)
+ static void remove_char_from_eof(CmdParams *p)
+ {
+ gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0);
+- gint last_line = SSM(p->sci, SCI_GETLINECOUNT, 0, 0);
+- gint line_end_pos = SSM(p->sci, SCI_GETLINEENDPOSITION, last_line, 0);
++ gint eof_pos = SSM(p->sci, SCI_GETLENGTH, 0, 0);
+
+- SET_POS(p->sci, line_end_pos, FALSE);
++ SET_POS(p->sci, eof_pos, FALSE);
+ SSM(p->sci, SCI_DELETEBACK, 0, 0);
+ SET_POS(p->sci, pos, FALSE);
+ }
+--
+2.31.1
+
Modified: geany_patches/04-geany_plugins_vimode_caret_fix.patch
65 lines changed, 65 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,65 @@
+From cb28b2f334d38bb78bcb15efd37f2c20172c499b Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= <techet at gmail.com>
+Date: Wed, 24 Nov 2021 00:13:29 +0100
+Subject: [PATCH] vimode: avoid caret position change when inserting EOL at EOF
+
+When current position is changed in the document and this position is
+outside the visibility of the current screen, when returning
+back, the call of SCI_GOTOPOS causes window scroll to a different position
+than before.
+
+To avoid this problem, insert_eof_nl_if_missing() and remove_char_from_eof()
+avoid setting the position now and, instead, insert/remove the EOL
+character using operations that don't change caret position.
+---
+ vimode/src/cmds/edit.c | 19 +++++++++++--------
+ 1 file changed, 11 insertions(+), 8 deletions(-)
+
+diff --git a/vimode/src/cmds/edit.c b/vimode/src/cmds/edit.c
+index 8e687257..ecdd0dd1 100644
+--- a/vimode/src/cmds/edit.c
++++ b/vimode/src/cmds/edit.c
+@@ -83,16 +83,21 @@ void cmd_clear_right(CmdContext *c, CmdParams *p)
+
+ static gboolean insert_eof_nl_if_missing(CmdParams *p)
+ {
+- gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0);
+ gint eof_pos = SSM(p->sci, SCI_GETLENGTH, 0, 0);
+ gint eof_line_num = SSM(p->sci, SCI_LINEFROMPOSITION, eof_pos, 0);
+ gint before_eof = PREV(p->sci, eof_pos);
+ gint before_eof_line_num = SSM(p->sci, SCI_LINEFROMPOSITION, before_eof, 0);
+
+ if (eof_line_num == before_eof_line_num) {
+- SET_POS(p->sci, eof_pos, FALSE);
+- SSM(p->sci, SCI_NEWLINE, 0, 0);
+- SET_POS(p->sci, pos, FALSE);
++ const gchar *nl = "\n";
++ gint eol_mode = SSM(p->sci, SCI_GETEOLMODE, 0, 0);
++ if (eol_mode == SC_EOL_CRLF) {
++ nl = "\r\n";
++ }
++ else if (eol_mode == SC_EOL_CR) {
++ nl = "\r";
++ }
++ SSM(p->sci, SCI_INSERTTEXT, eof_pos, (sptr_t)nl);
+ return TRUE;
+ }
+ return FALSE;
+@@ -101,12 +106,10 @@ static gboolean insert_eof_nl_if_missing(CmdParams *p)
+
+ static void remove_char_from_eof(CmdParams *p)
+ {
+- gint pos = SSM(p->sci, SCI_GETCURRENTPOS, 0, 0);
+ gint eof_pos = SSM(p->sci, SCI_GETLENGTH, 0, 0);
++ gint before_eof_pos = PREV(p->sci, eof_pos);
+
+- SET_POS(p->sci, eof_pos, FALSE);
+- SSM(p->sci, SCI_DELETEBACK, 0, 0);
+- SET_POS(p->sci, pos, FALSE);
++ SSM(p->sci, SCI_DELETERANGE, before_eof_pos, eof_pos - before_eof_pos);
+ }
+
+
+--
+2.31.1
+
Modified: geany_patches/05-geany_plugins_vimode_numlock_fix.patch
30 lines changed, 30 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,30 @@
+From 856f3f7ceaf54561a6fcca8707fe7ab5b444444c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= <techet at gmail.com>
+Date: Wed, 24 Nov 2021 15:48:55 +0100
+Subject: [PATCH] vimode: fix escape not working when numlock is on
+
+It seems that GDK_MOD2_MASK isn't the right modifier to check for
+command pressed - its mapping is platform-specific and while this works
+on macOS, it has undesirable side-effects on linux. Use GDK_META_MASK
+instead which based on my testing seems to do the right thing both on
+macOS and linux.
+---
+ vimode/src/keypress.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/vimode/src/keypress.c b/vimode/src/keypress.c
+index 66139a99..525c5ce3 100644
+--- a/vimode/src/keypress.c
++++ b/vimode/src/keypress.c
+@@ -26,7 +26,7 @@ KeyPress *kp_from_event_key(GdkEventKey *ev)
+ KeyPress *kp;
+
+ /* ignore keypresses containing Alt and Command on macOS - no Vim command uses them */
+- if (ev->state & (GDK_MOD1_MASK | GDK_MOD2_MASK))
++ if (ev->state & (GDK_MOD1_MASK | GDK_META_MASK))
+ return NULL;
+
+ switch (ev->keyval)
+--
+2.31.1
+
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list