From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Halim Newsgroups: gmane.emacs.bugs Subject: bug#61269: 28.2; Sequence of spaces preceding tab in bidirectional line Date: Sun, 05 Feb 2023 23:55:38 +0700 Message-ID: References: <83sfflu0cz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="879"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) To: 61269@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 05 18:04:24 2023 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 1pOiRC-000AcH-8g for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Feb 2023 18:04:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOiQu-00040s-8M; Sun, 05 Feb 2023 12:04:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOiQs-00040f-PX for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 12:04:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOiQs-00022v-AZ for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 12:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pOiQr-0005aj-Pk for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 12:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Halim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Feb 2023 17:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61269 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167561663921484 (code B ref -1); Sun, 05 Feb 2023 17:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Feb 2023 17:03:59 +0000 Original-Received: from localhost ([127.0.0.1]:46358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOiQo-0005aS-OV for submit@debbugs.gnu.org; Sun, 05 Feb 2023 12:03:59 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:50488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pOiQm-0005aK-KB for submit@debbugs.gnu.org; Sun, 05 Feb 2023 12:03:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOiQl-0003xa-2z for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 12:03:56 -0500 Original-Received: from mail-sgaapc01olkn2080c.outbound.protection.outlook.com ([2a01:111:f400:feab::80c] helo=APC01-SG2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOiQj-00021t-2W for bug-gnu-emacs@gnu.org; Sun, 05 Feb 2023 12:03:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HG8hkTAiFfF6u6+ruznNGo7dZm6A/WHLLahuH7VfI+/SB3vRnARg7eU7PpZk/sWEWlHqz9HQtu7rtibMdXmdgzh3IJpKCNWl1akPpa9SNLFXeNJUrSwS8a1ozVAJ2OGUAgP3aUZfdC/DInOJxHLr3oaNXZ7eaZ5nQF+o54DZhUCj3siQbCi+j75WEYmlBGx8jl6/ih9jiNv5sdbCEMrDM835TXj/CuZHFQ9kDcjC3qy+HrG+g/dK3IVbw0IHWrVE+wWCIRk0GnqHJLOGMA5KVI4G/JutTG/L7xqG657BqTUy+mKiRkRVCy53QQy0BC9qz3mG5PAzn6qXrlVfBUt6Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ppeTGO79VdfgLIDvMczuuLG9OpE5QZmyGBkZsfyF1x0=; b=ORr6uri8YmnTQDHD3UD+GT7szr4TkocVEvCnh7qeYPEzAgakeXsfDG9CfcyKrQw45260lAkiPDefVplNJvSq7mpZ/SzTC55Rtk0Po6SA40CoGHt88gjs0tNCzzczHjYsCrRmfIBymfPkZHpDy7nruh3HzF9PjDeiVlOfc2oH7HGDezPnYpMSHeedbw0eXbYDe6rdpa9eW5zsP9MFD5j//MeXiDVnxZ6T8dNuXlYEnBK/iN6SPsM+nwPPhUYFI1JfthB/K2Snm32iDuI0sev8bTGgn2QCSXZO3EOvN7oDd7D3D2GH0BqVyX6Z99pConFS87cWLf1oaJAWORCb+T9AVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ppeTGO79VdfgLIDvMczuuLG9OpE5QZmyGBkZsfyF1x0=; b=Hlj8N4FQeI3RFwkHqVaenWBQlsMJ9GFFP8wakHOz45TF71yCiwIsZW+4Dsr7ziZM/RG9/9A2cQyDoE6GBmpqT+hZcE/ETDHcC40ke2ETslL8IpxBB9daD/FPUjm6+uO4zkBm7im2FVD7Jys61+OAu8kHd6nBV148xuzuB110h8fEfNiJTJcqOUnsucJCd4o0Q8+tcZNFwPlHZAutX0oQ3rfu1CUE7q3ZOc1pJZ2lswxU/pJDMgAng94lBtYyv6W5BxVOHjq6sGOVqHtnjtqD3VOTq9Po1heZNi1C76PhI1jcTZIbCB2t9iqwIwV+sOWIoGQWEYD4aFe6uNeHTulUFg== Original-Received: from PUZPR06MB5451.apcprd06.prod.outlook.com (2603:1096:301:eb::9) by TYZPR06MB4349.apcprd06.prod.outlook.com (2603:1096:400:73::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.14; Sun, 5 Feb 2023 16:58:43 +0000 Original-Received: from PUZPR06MB5451.apcprd06.prod.outlook.com ([fe80::1fd9:df27:5c7d:36bf]) by PUZPR06MB5451.apcprd06.prod.outlook.com ([fe80::1fd9:df27:5c7d:36bf%8]) with mapi id 15.20.6086.010; Sun, 5 Feb 2023 16:58:43 +0000 In-Reply-To: <83sfflu0cz.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 04 Feb 2023 06:38:16 -0500") X-TMN: [ZQxl1m3ms0/uQa2sXRgdsYLEl3KEHGQ5] X-ClientProxiedBy: SI2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:194::16) To PUZPR06MB5451.apcprd06.prod.outlook.com (2603:1096:301:eb::9) X-Microsoft-Original-Message-ID: <87edr49hmd.fsf@outlook.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR06MB5451:EE_|TYZPR06MB4349:EE_ X-MS-Office365-Filtering-Correlation-Id: 99ceebea-ce90-4088-f159-08db079a3ce5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DE6icd0pKJkDuLdOYfrcLFy0+WeOCZJvxgj2/cLAHNL5OQZpR/dhvn3iquhZESIJMfsy4nXFzWVnD6CUK1Vo8f5cRGJ+vjcbj5WfTZz50mkUrjPjaSyPC5OiflFHIl/uZ1ddAlICnRax96vn0vZQmV7yUp3B3J0YqtoEVkvqlqP76XyRUuYkWXuBQpbeudyyoq/Fp45LnspSc71LUKEJR/7JBNQawKYMq89PSZ7J8T1pBzufjC4ZWiljCENJcWxcGvJRugShBnGrBlU5L4SYPxw/Tre1FLmgOmbexfUWIiNFk/gym0/9Oc1ECQIi6WlpcwivQtdRxqClwqliBMsBHE5+rD7jrEE2JoNQ9A60cf6HFlusEBki5CLttWVHZt+L4PidT4zfs+tzPx0rb89yohGc4JPzhCyEhj2eRBzl+4h129Wc4s6i1FlV/RHbSTJEtRyTH9hwRLKLtetZd0awWEUjIfgSRA8ebSurXa5hgJmbCMFcqq1+d6KG9G0tVRk+7C5VQn9iQBqVcPqwRKZ9LwcqbzfsJimEHVNvnk2VClQvbwy+fOUOlhKIws8ACv/Z57qEk0MQGxyXIOP/k8RU0b+9GILvcXknz0TpDOPlFX0= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MBhgB3sFnjcIsO8FZC4NuI1pfIXnFFmKSQYzmGsay7p+bitJKxUKNf8CHK/fVgJA08QUJ7mM/ajLjClWsvCO4+/2SfEe06kaRXJ4jsxuCBtf/b+qar2w/lUnoEX9jCb9M+qS1xMsN42ziBp7VdWuYC9Ks18a3cL+sgPuVU9crYJOCeyCiCUrQx5mKn3JXqIZyLeWZLbinngYVbLCB6BalMjo9uhucLsN84V/MiHumLoGJ2ivegyeRSQPBINFwVsOAnHqGS/CdcDKWYXPzSviGlKHFNdvogYofPwWqIj4vyJlcqYLgfVvWDgw92gbiKaDHu9uZBO3ZBzfznGunfhO25nBq4jqyIhKgzUxYUgXrmkr6DZD30Lfrn2IsAR/H4PcDIECOp6iKwfnaSjVCbvP1tPDVukTNlyB3EgOS8gbcz1yLyQmCQUUT4ee34NOYSHw1E/MsNj67EVm5WirZp/DbYQeXsAEWwQ78BZEU/PfIkIiRuC7eVaNOW5O2/F9waxXxfD8FW2EaCih95ZlmViQzFQRIlq32vSLEgUZmKfcn+GorYGcpvukJ2WDjANUqnCVuvdkUMCp5UsYjJm9XBXz0uhmMsOXNPMDAonjypD8wixhkK7d51+G5yOzIIGkO1TKJDZa5WgCP4phfHzQA+QMQ72gFuumVdQPUkgXQbYJN+DD9rfZfcykoDsxGOqxjL/BMO6ffq4fATFYJX4AOEiQCX95aD4eto2qFaNc/INX3q2tFw4g1R4FdCnCzN 0Y8QuyduX+nyhT+olSOIzxJoDUEHKPyUUF/67KOx4oupddgHqZFLO3ofJCdv7VP97dUNfH/fgVxl0MuKjPzmzqlN7n8eEGbDr2 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99ceebea-ce90-4088-f159-08db079a3ce5 X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5451.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2023 16:58:43.4877 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4349 Received-SPF: pass client-ip=2a01:111:f400:feab::80c; envelope-from=mhalimln@outlook.com; helo=APC01-SG2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254874 Archived-At: Eli Zaretskii writes: >> From: Halim >> Date: Sat, 04 Feb 2023 02:41:35 +0700 >>=20 >>=20 >> In a left-to-right line emacs display a sequence of one or more >> spaces (U+0020), where the spaces precede a tab (U+0009) and they >> both appear between two right-to-left alphabet, to the left of the >> first (in typing order) rtl alphabet. >>=20 >> The bug does not present when the rtl text is inside an rtl >> isolate. >>=20 >> Let s represent space, t represet tab, l represent itself, r and >> m represent arabic alphabet. The following example have this format >> in typing order from left to right. >>=20 >> Format: >> lsrssstm >>=20 >> Example text: >> l =D8=AD =D9=85 >>=20 >> The expected display is 'lsrssstm', the actual is 'lssssrtm'. >> The spaces following 'r' in the format is displayed to the left >> of 'r' in the actual display. Using 'C-f' from 'r' moves the >> cursor to the left until it hits 't' where the cursor move to >> the right of 'r'. >>=20 >> I have tried to view the file containing the buggy text in >> focuswriter and fribidi. They both display the same expected >> way. >>=20 >> Extra Info >>=20 >> The bug also present to ltr text on rtl line. I believe >> this is generic and is caused by this line >> '&& level !=3D bidi_it->level_stack[0].level' (see below). >>=20 >> The bug also present in emacs built from commit >> 'ac7ec87a7a0db887e4ae7fe9005aea517958b778' with >> --without-all. In this commit I make the following >> modification. >>=20 >> --------------- >> $ git diff ac7ec87a7a0db887e4ae7fe9005aea517958b778 >> diff --git a/src/bidi.c b/src/bidi.c >> index e012512..fe6e4d6 100644 >> --- a/src/bidi.c >> +++ b/src/bidi.c >> @@ -3302,10 +3302,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) >> if ((bidi_it->orig_type =3D=3D NEUTRAL_WS >> || bidi_it->orig_type =3D=3D WEAK_BN >> || bidi_isolate_fmt_char (bidi_it->orig_type)) >> - && bidi_it->next_for_ws.charpos < bidi_it->charpos >> - /* If this character is already at base level, we don't need to >> - reset it, so avoid the potentially costly loop below. */ >> - && level !=3D bidi_it->level_stack[0].level) >> + && bidi_it->next_for_ws.charpos < bidi_it->charpos) >> { >> int ch; >> ptrdiff_t clen =3D bidi_it->ch_len; >> --------------- >>=20 >> It fixes the bug. > > Thanks. > > You are right that the logic there was flawed. However, just removing > the base-level test is sub-optimal: that test was added to speed up > redisplay when the buffer has a lot of control characters (e.g., > binary null bytes) that don't need to be reordered; see bug#22739. > > So I have installed a slightly different change, reproduced below; > please see that it solves the problem, including (presumably) some > real-life problems you had in displaying RTL text with embedded TABs. > > diff --git a/src/bidi.c b/src/bidi.c > index e012512..93875d2 100644 > --- a/src/bidi.c > +++ b/src/bidi.c > @@ -3300,12 +3300,15 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) > it belongs to a sequence of WS characters preceding a newline > or a TAB or a paragraph separator. */ > if ((bidi_it->orig_type =3D=3D NEUTRAL_WS > - || bidi_it->orig_type =3D=3D WEAK_BN > + || (bidi_it->orig_type =3D=3D WEAK_BN > + /* If this BN character is already at base level, we don't > + need to consider resetting it, since I1 and I2 below > + will not change the level, so avoid the potentially > + costly loop below. */ > + && level !=3D bidi_it->level_stack[0].level) > || bidi_isolate_fmt_char (bidi_it->orig_type)) > - && bidi_it->next_for_ws.charpos < bidi_it->charpos > - /* If this character is already at base level, we don't need to > - reset it, so avoid the potentially costly loop below. */ > - && level !=3D bidi_it->level_stack[0].level) > + /* This means the informaition about WS resolution is not valid. = */ > + && bidi_it->next_for_ws.charpos < bidi_it->charpos) > { > int ch; > ptrdiff_t clen =3D bidi_it->ch_len; > @@ -3340,7 +3343,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it) > || bidi_it->orig_type =3D=3D NEUTRAL_S > || bidi_it->ch =3D=3D '\n' || bidi_it->ch =3D=3D BIDI_EOB > || ((bidi_it->orig_type =3D=3D NEUTRAL_WS > - || bidi_it->orig_type =3D=3D WEAK_BN > + || bidi_it->orig_type =3D=3D WEAK_BN /* L1/Retaining */ > || bidi_isolate_fmt_char (bidi_it->orig_type) > || bidi_explicit_dir_char (bidi_it->ch)) > && (bidi_it->next_for_ws.type =3D=3D NEUTRAL_B I have done the same test as I did before and your patch does fix the problem. Unfortunately I never had any real-life problems as I did not write any bidi text (I does write, but its only to help my understanding on UBA), so I cant give any result on this. Thanks.