From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31285 invoked from network); 10 Jan 2023 16:56:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Jan 2023 16:56:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:From:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=2VO3DuX0aNL8DQVMzoG/WbxKwEG9ftTERBDVd0+TPfs=; b=nSYtUs7mSM+zIVw0fLfLzDx6Pe Mx9gVp5z4gKj6kUbNnjGRjIisMVZRHPfqfITYsWPeRd7x4/iXZFu2LSe0QmYoXsCkSsSi9Ba7g4dp WLdOUEjBbEalUeoIalULI1EzC2qI7xC5QNfLaRgKEyzbENKOKYzrZ+xcX7y6jxuUeEsbv4sRAlkuR HnXJqvFQNYsMBjqJqE82kJtR7lELfvlzmeHVPiEP99fEghTSrVVprEKY36rKiHAjY7sV8GiTBocCF ZFVhaf37GYQz3/9kyCj20cIn+P3g+JdMdVcAwAUDA569OlLWJrZhpqxmTiLXU7rdgnJrVFrB01BI+ ryLz8yoA==; Received: by zero.zsh.org with local id 1pFHux-0009w9-GG; Tue, 10 Jan 2023 16:56:07 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pFHuQ-0009bz-OO; Tue, 10 Jan 2023 16:55:34 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pFHuP-000O9O-H8 for zsh-workers@zsh.org; Tue, 10 Jan 2023 17:55:33 +0100 From: Oliver Kiddle To: Zsh workers Subject: PATCH: fix updates to region_highlight, accounting for PREDISPLAY MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <92836.1673369733.1@hydra> Date: Tue, 10 Jan 2023 17:55:33 +0100 Message-ID: <92837-1673369733.527434@Np6E.5Ah8.qv5l> X-Seq: 51292 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: I've been paying more attention than usual to any glitches related to terminal attributes and this fixes an old bug where dynamic updates to region_highlight failed to allow for the PREDISPLAY part of the buffer. You can see this bug by invoking Functions/Zle/replace-string, typing a few characters and then using backspace - bold highlighting is lost. I think the intention in read-from-minibuffer is that bold is only used for the prompt. But the user-entered string starts empty and when new characters are added to the right of a region_highlight entry, they are included. We could solve this by excluding bold highlighting for the final space in the read-from-minibuffer prompt but the prompt is a parameter and may not end in a space. It would be possible to add ZRH_* flags and some syntax for whether regions expand for new characters at the left and right. Or perhaps just make a special case for the end of PREDISPLAY? I'm not certain of the code path to reach the meta half of shiftchars(). Oliver diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 1a580a9e6..45a82dd5e 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -866,13 +866,13 @@ shiftchars(int to, int cnt) if (rhp->start_meta - sub > to + cnt) rhp->start_meta -= cnt; else - rhp->start_meta = to; + rhp->start_meta = to + sub; } if (rhp->end_meta - sub > to) { if (rhp->end_meta - sub > to + cnt) rhp->end_meta -= cnt; else - rhp->end_meta = to; + rhp->end_meta = to + sub; } } } @@ -896,13 +896,13 @@ shiftchars(int to, int cnt) if (rhp->start - sub > to + cnt) rhp->start -= cnt; else - rhp->start = to; + rhp->start = to + sub; } if (rhp->end - sub > to) { if (rhp->end - sub > to + cnt) rhp->end -= cnt; else - rhp->end = to; + rhp->end = to + sub; } } }