Index | Thread | Search

From:
YASUOKA Masahiko <yasuoka@openbsd.org>
Subject:
Re: libedit: porting request
To:
schwarze@openbsd.org, tech@openbsd.org
Cc:
naito.yuichiro@gmail.com
Date:
Mon, 19 Jan 2026 17:52:14 +0900

Download raw body.

Thread
On Mon, 19 Jan 2026 15:34:27 +0900
Yuichiro NAITO <naito.yuichiro@gmail.com> wrote:
> Does anybody please port the following NetBSD patch to OpenBSD?

Yes.  Thank you for the fix.

> You can apply this patch simply to the OpenBSD src.
> 
> https://github.com/NetBSD/src/commit/964e441ae0de9ef8ef53f77dddf4aa1ced782c15
> 
> This patch fixes an issue where long editing command lines will
> overwrite the last help messages.
> 
> You can reproduce this issue with the sample program in the commit
> message. Just compile the sample code and run it. While you're
> editing a command more than one line, typing '?' will show the help
> message, but the last help message will be overwritten, so users
> miss it. This patch solves this issue.

I tested the diff fixes the same problem happening on OpenBSD.

ok?

Index: lib/libedit/refresh.c
===================================================================
RCS file: /cvs/src/lib/libedit/refresh.c,v
diff -u -p -r1.23 refresh.c
--- lib/libedit/refresh.c	8 Mar 2023 04:43:05 -0000	1.23
+++ lib/libedit/refresh.c	19 Jan 2026 08:38:14 -0000
@@ -1163,16 +1163,24 @@ re_clear_display(EditLine *el)
 protected void
 re_clear_lines(EditLine *el)
 {
+	int i;
 
 	if (EL_CAN_CEOL) {
-		int i;
 		for (i = el->el_refresh.r_oldcv; i >= 0; i--) {
+			if (i > 0) {
+				terminal__putc(el, '\r');
+				terminal__putc(el, '\n');
+			}
 			/* for each line on the screen */
 			terminal_move_to_line(el, i);
 			terminal_move_to_char(el, 0);
 			terminal_clear_EOL(el, el->el_terminal.t_size.h);
 		}
 	} else {
+		for (i = el->el_refresh.r_oldcv; i > 0; i--) {
+			terminal__putc(el, '\r');
+			terminal__putc(el, '\n');
+		}
 		terminal_move_to_line(el, el->el_refresh.r_oldcv);
 					/* go to last line */
 		terminal__putc(el, '\r');	/* go to BOL */