lichray / nvi2

A multibyte fork of the nvi editor for BSD
Other
144 stars 34 forks source link

Cannot insert blank line after command separator #135

Open mohd-akram opened 3 months ago

mohd-akram commented 3 months ago

This is a similar issue to #134, reproduced like so:

$ printf '%s\n' 'a|' . %p | nvi -e

This should print a newline. A potential fix:

--- a/ex/ex_append.c
+++ b/ex/ex_append.c
@@ -179,7 +179,9 @@ ex_aci(SCR *sp, EXCMD *cmdp, enum which cmd)
        if (len != 0)
            cmdp->save_cmd = t;
        cmdp->save_cmdlen = len;
-   }
+   } else if ((cmdp->save_cmd[-1] == '\n' || cmdp->save_cmd[-1] == '|') &&
+       db_append(sp, 1, lno++, NULL, 0))
+       return (1);

    if (F_ISSET(sp, SC_EX_GLOBAL)) {
        if ((sp->lno = lno) == 0 && db_exist(sp, 1))

EDIT: Updated the patch for this scenario too:

g/enum/i\
<newline>