From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43394-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 737da202 for ; Thu, 6 Sep 2018 03:47:44 +0000 (UTC) Received: (qmail 6729 invoked by alias); 6 Sep 2018 03:47:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43394 Received: (qmail 14917 invoked by uid 1010); 6 Sep 2018 03:47:30 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f181.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.208.181):SA:0(-1.9/5.0):. Processed in 4.247992 secs); 06 Sep 2018 03:47:30 -0000 X-Envelope-From: leomaoyw@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ZzfOYBv6tlIYJAN8H5xlFvMdW7klfirQkMQTbzlRMgQ=; b=c/LCc9t/ADGJasb5nIcUkPxOJjOePWl3Cz+jDu+dX+qHUi6Ko96GlXTgaxayzGAfvG 9jeB4mF06EBDb+mgL2TyUoG4aEHRXDsxZPE1zNHdcEwr2/0JCdfsV7BUbnQVsOG1NJ+F WjvRQo3M/+Xrx34VSxoVMSRZhQJc5T8gc3ZB+NqeK8z+DvMzVFpp4KFTJC52ApcW+Dzc lPM/zy3T6FWu81IQz5TZ/AZIqOprSAeHv3dxIWK6tJZU3tFqkLmI611OWNkG1o8usKrM sg8XTU85lGtN+vzyUMOMxQiU8p0cNNAr1Gje7OiaRb0sETRQTG4hqqmp0yLVluf3JwZd c9lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZzfOYBv6tlIYJAN8H5xlFvMdW7klfirQkMQTbzlRMgQ=; b=okH2gcDR6nXI19ZA68T/lALpF/Hl1yXXjok/O5HAJwDqAdv38FuCWRAIw8HIFkIkd0 5OWhDloqBHBYvVfSayo3opVTyQYBQjUMvQFOJHqHFQ3WpNRGBSkhMwqM1wfk7cBmFm/o IXgHBJi8v7AttS10wUFD2zCKfj6xpzPtQTyJq8jd1qvMyXrZ+KeGqc8ff9vbVPOnmKtb SYy9uBz5+LFtP0MmLrmhXFHGkLDT5DMp52uVFNFfGuqC9tlTr5wr4BhElYPkv6LbT64Y NS7tFHdReowl2NQaWx3ZIgJBtRt3aVSPi771MwjaELLGWWqZpuTgq1eXCH26h2XcnnCv +PeQ== X-Gm-Message-State: APzg51Ddwk6sPjc+9eWcq0oaeezq709YeWQWAz5eVvMuBmufQhhFd4ig nivVrGuKsvMpoC8t+4YD6qodGou/ajipcr757EuflcEM X-Google-Smtp-Source: ANB0VdYiiOBvAGGEw5N0/hyj5rM9jutay8s5HHSIrhMsmeQfx4RC5ZZ5KD79eU01yLU79ISYAB+/cyIg2nI6/W7+KYs= X-Received: by 2002:a2e:5719:: with SMTP id l25-v6mr379822ljb.125.1536205641620; Wed, 05 Sep 2018 20:47:21 -0700 (PDT) MIME-Version: 1.0 From: Yao-Wen Mao Date: Thu, 6 Sep 2018 11:47:10 +0800 Message-ID: Subject: [PATCH] move the cursor up only when redisplay is called the first time To: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="0000000000009221c505752bbf9f" --0000000000009221c505752bbf9f Content-Type: text/plain; charset="UTF-8" Last year I found an issue about reset-prompt with multiline prompt. (Thread: `reset-prompt` multiple times cause multiline PROMPT redraw in the wrong place) When using mutliline prompt, ` lprompth` will be greater than 1. Now if `redisplay` in zle_refresh.c is called multiple times without calling `resetvideo`, then the cursor position will move to the wrong place. To verify this, I create an ugly fix and rebuild to check that the problem is gone. I add a flag `cursor_moved` to make sure that the cursor will only move once before calling `resetvideo`. I think this may not be a proper fix, is there anyone can help me to create a better fix? diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index d0dd1ef06..1d1b2526e 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -210,6 +210,8 @@ int predisplaylen, postdisplaylen; static int default_atr_on, special_atr_on; +static int cursor_moved; + /* * Array of region highlights, no special termination. * The first element (0) always describes the region between @@ -771,6 +773,8 @@ resetvideo(void) if (showinglist > 0) showinglist = -2; trashedzle = 0; + + cursor_moved = 0; } /* @@ -2433,7 +2437,9 @@ redisplay(UNUSED(char **args)) { moveto(0, 0); zputc(&zr_cr); /* extra care */ - tc_upcurs(lprompth - 1); + if (!cursor_moved) + tc_upcurs(lprompth - 1); + cursor_moved = 1; resetneeded = 1; clearflag = 0; return 0; --0000000000009221c505752bbf9f--