Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Incorrect cursor position when ZLE_RPROMPT_INDENT=0 (with a fix)



Is there anything else I need to do to move this forward? The patch works on all terminals I and others have tried (11 in total; some with multiple versions and/or configurations). The code no longer special-cases ZLE_RPROMPT_INDENT=0, which is nice. There is branch for ZLE_RPROMPT_INDENT=0 but it's just an optimization to avoid an unnecessary zputc(&zr_cr) call when it's known to have no effect. So I think the logic is simpler now.

I've attached the patch to the email. You can also find it at https://github.com/zsh-users/zsh/compare/master...romkatv:rprompt-indent.

Roman.
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 1f293845f..85e55e0d4 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1678,7 +1678,12 @@ zrefresh(void)
 
 	    moveto(0, winw - rprompt_off - rpromptw);
 	    zputs(rpromptbuf, shout);
-	    vcs = winw - rprompt_off;
+	    if (rprompt_off) {
+		vcs = winw - rprompt_off;
+	    } else {
+		zputc(&zr_cr);
+		vcs = 0;
+	    }
 	/* reset character attributes to that set by the main prompt */
 	    txtchange = pmpt_attr;
 	    /*
@@ -2159,25 +2164,20 @@ moveto(int ln, int cl)
     const REFRESH_ELEMENT *rep;
 
     if (vcs == winw) {
-	if (rprompt_indent == 0 && tccan(TCLEFT)) {
-	  tc_leftcurs(1);
-	  vcs--;
-	} else {
-	    vln++, vcs = 0;
-	    if (!hasam) {
-		zputc(&zr_cr);
-		zputc(&zr_nl);
-	    } else {
-		if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)
-		    rep = nbuf[vln];
-		else
-		    rep = &zr_sp;
-		zputc(rep);
-		zputc(&zr_cr);
-		if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)
-		    *obuf[vln] = *rep;
-	    }
-	}
+    vln++, vcs = 0;
+    if (!hasam) {
+	zputc(&zr_cr);
+	zputc(&zr_nl);
+    } else {
+	if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr)
+	    rep = nbuf[vln];
+	else
+	    rep = &zr_sp;
+	zputc(rep);
+	zputc(&zr_cr);
+	if ((vln < olnct) && obuf[vln] && obuf[vln]->chr)
+	    *obuf[vln] = *rep;
+    }
     }
 
     if (ln == vln && cl == vcs)


Messages sorted by: Reverse Date, Date, Thread, Author