On Tue, Mar 08, 2022 at 03:15:55PM +0300, Mikhail wrote:
> Inlined diff helps ksh search-history function (ctrl-r) to handle
> backspace for UTF8 characters properly, without the patch, if I have
> UTF8 characters in my search buffer, I need to press backspace twice to
> push cursor to the left.
> 
> The search itself is not perfect for UTF8 either, sometimes I get
> patterns which are not handled properly, or the input prompt becomes
> mangled, but the issue with backspace is what currently bothers me the
> most.
> 
> Comments, objections?

Better version, behavior is not changed:


diff --git bin/ksh/emacs.c bin/ksh/emacs.c
index 5370e814f70..a5ed4095ae5 100644
--- bin/ksh/emacs.c
+++ bin/ksh/emacs.c
@@ -907,8 +907,11 @@ x_search_hist(int c)
                                offset = -1;
                                break;
                        }
-                       if (p > pat)
-                               *--p = '\0';
+                       if (p > pat) {
+                               while (isu8cont(*--p))
+                                       ;
+                               *p ='\0';
+                       }
                        if (p == pat)
                                offset = -1;
                        else

Reply via email to