From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#41506: 28.0.50; RTL problem Date: Sat, 06 Jun 2020 07:58:24 +0000 Message-ID: <87k10kzkv3.fsf@gmail.com> References: <838shhxuff.fsf@gnu.org> <83tuztctpk.fsf@gnu.org> <83ftbdcmm3.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="88572"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 41506@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 06 09:59:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jhTjT-000N0K-U3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jun 2020 09:59:12 +0200 Original-Received: from localhost ([::1]:53710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhTjS-0004yZ-UO for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jun 2020 03:59:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhTjL-0004y9-08 for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 03:59:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhTjK-00068q-O6 for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 03:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jhTjK-0005jR-OK for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 03:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jun 2020 07:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41506 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 41506-submit@debbugs.gnu.org id=B41506.159143033421998 (code B ref 41506); Sat, 06 Jun 2020 07:59:02 +0000 Original-Received: (at 41506) by debbugs.gnu.org; 6 Jun 2020 07:58:54 +0000 Original-Received: from localhost ([127.0.0.1]:50608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhTiy-0005iP-I3 for submit@debbugs.gnu.org; Sat, 06 Jun 2020 03:58:54 -0400 Original-Received: from mail-lj1-f179.google.com ([209.85.208.179]:35811) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhTiw-0005iB-Jr for 41506@debbugs.gnu.org; Sat, 06 Jun 2020 03:58:39 -0400 Original-Received: by mail-lj1-f179.google.com with SMTP id j18so1461968lji.2 for <41506@debbugs.gnu.org>; Sat, 06 Jun 2020 00:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=vjxUGLCtaV8xZxSEBTxSD/MIgugve7EYg3K9IVIpJGA=; b=q4DWW9XUrEsZEyXj3QEoTcZo1isUNeZcwaUxP5UmK+0KOib68/UE8lzuivvqBeA+VF MMSX3O429KomRwNNqtvXAJImtXhj/vurHlTQI3uVoCmhjlhKo0lAU645naZITMn+Cbua Q010vGjNCtRJ9ycUd+vR7LI0WbSWwBaDFlR121VwQcMbYwKLVPOh91WfhTCtzoxQOGyo PJFl6xvVrNs1iFfVsQx4lc9jsAbFtj+OoTvbVnFSlRPZqVRvH+Zj5dhGZCrMzBxlquV1 eGIEp1OssRzte7b3o7KNnMs4HVsnrSNwqByjGSqCPhw8SCMhYEUeTY6AlFf42e8HC+sl VhMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=vjxUGLCtaV8xZxSEBTxSD/MIgugve7EYg3K9IVIpJGA=; b=t16oyomwS1CM2qknhr/aQ0LcW9xM/CvPCjM/LT1x4zESZ50urs12+Nlinhhn2brgNI opQeNWhkKrylQu4z3ataAaqjk5vwa9FBO//klSSqIBS7eEITldjJ1lk+9yQl0wp7in9C JiWQJV+dvEEY77HGODOioOvGvSKQsKz43F68sf0LIqvmjSk9bHILZSPkzF6mjH3EsxWe p0hhK35lubxS6+LrhVr4DP8/1v8h5lr5JkeCMK5lrecERrLWiRzU8JDVHUru4Xzbwo5E IROOK1KORs/z6R+dOODMCD6sq6JBbXfbgfWj4LLfJO3G73amKtMuccyjTR06pyri0iXR SeUQ== X-Gm-Message-State: AOAM533ZWhZJYhqIWql05I5pYiZh1rK5uBStmVpBAXCXq62Py+Y2gKFz P69sLMU9yk0WNqq21p8mnppO3/99f+0= X-Google-Smtp-Source: ABdhPJzhX/op5/1smNYIxfJIDkRWT3poMg0s/UhnpYDiLzU2E3Go4VhcfPQ5Y8nHzD6RQ9XrR1mOyQ== X-Received: by 2002:a2e:8754:: with SMTP id q20mr6773520ljj.270.1591430311978; Sat, 06 Jun 2020 00:58:31 -0700 (PDT) Original-Received: from chametz (tor-exit1-readme.dfri.se. [171.25.193.77]) by smtp.gmail.com with ESMTPSA id r17sm1747900ljd.0.2020.06.06.00.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jun 2020 00:58:31 -0700 (PDT) In-Reply-To: <83ftbdcmm3.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 02 Jun 2020 22:07:48 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181592 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Tue, 02 Jun 2020 19:34:31 +0300 >> From: Eli Zaretskii >> Cc: 41506@debbugs.gnu.org >> >> So I guess whatever issues I had back then were meanwhile solved "by >> other means", and you should install this patch. If there is indeed >> some subtlety here, it will present itself sooner or later (like, in >> another 11 years). > > Btw, please note that some residual problem remains: after the patch, > if a buffer begins with 2 newlines and an RTL letter, the first screen > line is rendered right-to-left, which is wrong. You can see that it's > wrong if you insert more newlines at BOB: then only the single empty > line immediately before the RTL letter is rendered right-to-left. > > Of course, this is better than the original problem. I decided to investigate further, and finally came up with this patch, which appears to work. I'm not a hundred percent sure it's the right thing to do, because when we're called with bidi_it->first_elt = true, it's possible we shouldn't touch bidi_it->new_paragraph at all... --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Handle-buffers-containing-two-newlines-followed-by-a.patch >From b5302d2e89710166cc8540c8fc08a7eaabc341f4 Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 6 Jun 2020 07:52:13 +0000 Subject: [PATCH] Handle buffers containing two newlines followed by an RTL char * src/bidi.c (bidi_paragraph_init): Correct handling of initial newlines. (Bug#41506) --- src/bidi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bidi.c b/src/bidi.c index 1017bd2d52..8d2d3c1f07 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -1707,14 +1707,14 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p) return; /* If we are on a newline, get past it to where the next - paragraph might start. But don't do that at BEGV since then - we are potentially in a new paragraph that doesn't yet - exist. */ + paragraph might start. But don't do that for the first + element since this function will be called twice in that + case. */ pos = bidi_it->charpos; s = (STRINGP (bidi_it->string.lstring) ? SDATA (bidi_it->string.lstring) : bidi_it->string.s); - if (bytepos > begbyte + if (!bidi_it->first_elt && bidi_char_at_pos (bytepos, s, bidi_it->string.unibyte) == '\n') { bytepos++; -- 2.27.0.rc0 --=-=-= Content-Type: text/plain If you have any further comments, I'd be glad to amend the comments in bidi.c to reflect what we actually do understand. --=-=-=--