tvi: reset vi_soset in ^a command - neatvi - [fork] simple vi-type editor with UTF-8 support
 (HTM) git clone git://src.adamsgaard.dk/neatvi
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 19e46a1b49c9d49bb2d4161dd6acf4727c15749d
 (DIR) parent 8fbb8b3a23c593b84d3bc4218329226d6b0cdb59
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Sun, 21 Nov 2021 00:08:11 +0330
       
       vi: reset vi_soset in ^a command
       
       Diffstat:
         M vi.c                                |      13 +++++++------
       
       1 file changed, 7 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/vi.c b/vi.c
       t@@ -258,7 +258,7 @@ static int vi_search(int cmd, int cnt, int *row, int *off)
                char *kwd;
                int r = *row;
                int o = *off;
       -        int failed = 0;
       +        char *failed = NULL;
                int len = 0;
                int i, dir;
                if (cmd == '/' || cmd == '?') {
       t@@ -289,7 +289,7 @@ static int vi_search(int cmd, int cnt, int *row, int *off)
                o = *off;
                for (i = 0; i < cnt; i++) {
                        if (lbuf_search(xb, kwd, dir, &r, &o, &len)) {
       -                        failed = 1;
       +                        failed = " not found";
                                break;
                        }
                        if (i + 1 < cnt && cmd == '/')
       t@@ -301,14 +301,14 @@ static int vi_search(int cmd, int cnt, int *row, int *off)
                        if (vi_soset) {
                                *off = -1;
                                if (*row + vi_so < 0 || *row + vi_so >= lbuf_len(xb))
       -                                failed = 1;
       +                                failed = " bad offset";
                                else
                                        *row += vi_so;
                        }
                }
       -        if (failed)
       -                snprintf(vi_msg, sizeof(vi_msg), "\"%s\" not found\n", kwd);
       -        return failed;
       +        if (failed != NULL)
       +                snprintf(vi_msg, sizeof(vi_msg), "/%s/%s\n", kwd, failed ? failed : "");
       +        return failed != NULL;
        }
        
        /* read a line motion */
       t@@ -543,6 +543,7 @@ static int vi_motion(int *row, int *off)
                        if (!(cs = vi_curword(xb, *row, *off)))
                                return -1;
                        ex_kwdset(cs, +1);
       +                vi_soset = 0;
                        free(cs);
                        if (vi_search('n', cnt, row, off))
                                return -1;