[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-readline] make ';' after 't' work in vi-mode
From: |
Richard Todd |
Subject: |
Re: [Bug-readline] make ';' after 't' work in vi-mode |
Date: |
Wed, 26 Sep 2018 23:20:45 +0000 |
On Wed, Sep 26, 2018 at 03:36:47PM -0500, Richard Todd wrote:
> The following small patch (against git devel) addresses the
> issue for me.
The first patch I sent had errors when compiling without
MULTIBYTE. I've tried it both ways now; here's the
revised patch for your consideration.
diff --git a/vi_mode.c b/vi_mode.c
index d6fa38e..cdd8ec7 100644
--- a/vi_mode.c
+++ b/vi_mode.c
@@ -1768,6 +1768,26 @@ _rl_vi_callback_char_search (_rl_callback_generic_arg
*data)
}
#endif
+#if defined (HANDLE_MULTIBYTE)
+static int
+_rl_vi_nextchar_is(int dir, char *smbchar, int len)
+#else
+static int
+_rl_vi_nextchar_is(int dir, char schar)
+#endif
+{
+ int pos = rl_point;
+
+#if defined (HANDLE_MULTIBYTE)
+ pos = (dir > 0) ? _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)
+ : _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);
+ return _rl_is_mbchar_matched (rl_line_buffer, pos, rl_end, smbchar, len);
+#else
+ pos += (dir < 0) ? -1 : 1;
+ return rl_line_buffer[pos] == schar;
+#endif
+}
+
int
rl_vi_char_search (int count, int key)
{
@@ -1791,6 +1811,16 @@ rl_vi_char_search (int count, int key)
return 1;
#endif
_rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir;
+
+#if defined (HANDLE_MULTIBYTE)
+ if ((_rl_cs_dir == FTO || _rl_cs_dir == BTO) &&
+ _rl_vi_nextchar_is (_rl_cs_dir, _rl_vi_last_search_mbchar,
_rl_vi_last_search_mblen))
+ ++count;
+#else
+ if ((_rl_cs_dir == FTO || _rl_cs_dir == BTO) &&
+ _rl_vi_nextchar_is (_rl_cs_dir, _rl_vi_last_search_char))
+ ++count;
+#endif
}
else
{