Bug 4526

Summary: vi: fix end key "lock" which require Ctrl+c
Product: Busybox Reporter: Tanguy Pruvot <tanguy.pruvot>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs, tanguy.pruvot
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description Tanguy Pruvot 2011-11-23 22:20:28 UTC
In trunk (1.20) There is a problem when we hit the "End" key

This patch fix the lock in navigation mode, but there is another problem in Insert Mode (invalid char)
Comment 1 Tanguy Pruvot 2011-11-24 02:23:32 UTC
sorry, was already fixed :p

*** This bug has been marked as a duplicate of bug 4153 ***
Comment 2 Tanguy Pruvot 2011-11-24 22:38:22 UTC
diff --git a/editors/vi.c b/editors/vi.c
index 71d6008..8a28212 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3069,9 +3069,8 @@ static void do_cmd(int c)
        int cnt, i, j;
        int c1;

-//     c1 = c; // quiet the compiler
-//     cnt = yf = 0; // quiet the compiler
-//     p = q = save_dot = buf; // quiet the compiler
+       c1 = cnt = 0;
+       p = q = save_dot = NULL;
        memset(buf, '\0', sizeof(buf));

        show_status_line();
@@ -3317,12 +3316,19 @@ static void do_cmd(int c)
 #endif /* FEATURE_VI_YANKMARK */
        case '$':                       // $- goto end of line
        case KEYCODE_END:               // Cursor Key End
+               if (--cmdcnt > 0) {
+                       dot_next();
+                       do_cmd(c);
+               }
+               dot = end_line(dot);
+/*
                for (;;) {
                        dot = end_line(dot);
                        if (--cmdcnt > 0)
                                break;
                        dot_next();
                }
+*/
                break;
        case '%':                       // %- find matching char of pair () [] {}
                for (q = dot; q < end && *q != '\n'; q++) {
Comment 3 Denys Vlasenko 2011-11-28 03:56:04 UTC
The fix is simple: if (--cmdcnt > 0) condition should be reversed: f (--cmdcnt <= 0)

Fixed in git.