On Tue, 09 Mar 2021 17:53:06 +0100, Benjamin Baier wrote:

> Ping

I think that in do_clear_screen() full should not be set unless
neednl is 0.  That is, we should only print the entire prompt if
the screen was actually cleared.  Otherwise looks good to me.

 - todd

Index: bin/ksh/vi.c
===================================================================
RCS file: /cvs/src/bin/ksh/vi.c,v
retrieving revision 1.57
diff -u -p -u -r1.57 vi.c
--- bin/ksh/vi.c        20 Sep 2020 14:40:45 -0000      1.57
+++ bin/ksh/vi.c        9 Mar 2021 17:02:14 -0000
@@ -55,7 +55,7 @@ static int    Endword(int);
 static int     grabhist(int, int);
 static int     grabsearch(int, int, int, char *);
 static void    do_clear_screen(void);
-static void    redraw_line(int);
+static void    redraw_line(int, int);
 static void    refresh_line(int);
 static int     outofwin(void);
 static void    rewindow(void);
@@ -719,7 +719,7 @@ vi_cmd(int argcnt, const char *cmd)
                        break;
 
                case CTRL('r'):
-                       redraw_line(1);
+                       redraw_line(1, 0);
                        break;
 
                case '@':
@@ -1737,18 +1737,19 @@ do_clear_screen(void)
                        neednl = 0;
        }
 #endif
-       redraw_line(neednl);
+       /* Only print the full prompt if we cleared the screen. */
+       redraw_line(neednl, !neednl);
 }
 
 static void
-redraw_line(int neednl)
+redraw_line(int neednl, int full)
 {
        (void) memset(wbuf[win], ' ', wbuf_len);
        if (neednl) {
                x_putc('\r');
                x_putc('\n');
        }
-       vi_pprompt(0);
+       vi_pprompt(full);
        cur_col = pwidth;
        morec = ' ';
 }
@@ -2109,7 +2110,7 @@ complete_word(int command, int count)
                        vi_error();
                        x_print_expansions(nwords, words, is_command);
                        x_free_words(nwords, words);
-                       redraw_line(0);
+                       redraw_line(0, 0);
                        return -1;
                }
                /*
@@ -2183,7 +2184,7 @@ print_expansions(struct edstate *e)
        }
        x_print_expansions(nwords, words, is_command);
        x_free_words(nwords, words);
-       redraw_line(0);
+       redraw_line(0, 0);
        return 0;
 }
 

Reply via email to