1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 22:41:06 -08:00

Fix bidi reordering of sequence of whitespace characters before a TAB

* src/bidi.c (bidi_level_of_next_char): Test the current level
only for characters whose original type is BN.  (Bug#61269)
This commit is contained in:
Eli Zaretskii 2023-02-04 13:34:42 +02:00
parent 8870b54db9
commit 1a123feb18

View file

@ -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 it belongs to a sequence of WS characters preceding a newline
or a TAB or a paragraph separator. */ or a TAB or a paragraph separator. */
if ((bidi_it->orig_type == NEUTRAL_WS if ((bidi_it->orig_type == NEUTRAL_WS
|| bidi_it->orig_type == WEAK_BN || (bidi_it->orig_type == 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 != bidi_it->level_stack[0].level)
|| bidi_isolate_fmt_char (bidi_it->orig_type)) || bidi_isolate_fmt_char (bidi_it->orig_type))
&& bidi_it->next_for_ws.charpos < bidi_it->charpos /* This means the informaition about WS resolution is not valid. */
/* If this character is already at base level, we don't need to && bidi_it->next_for_ws.charpos < bidi_it->charpos)
reset it, so avoid the potentially costly loop below. */
&& level != bidi_it->level_stack[0].level)
{ {
int ch; int ch;
ptrdiff_t clen = bidi_it->ch_len; ptrdiff_t clen = bidi_it->ch_len;
@ -3340,7 +3343,7 @@ bidi_level_of_next_char (struct bidi_it *bidi_it)
|| bidi_it->orig_type == NEUTRAL_S || bidi_it->orig_type == NEUTRAL_S
|| bidi_it->ch == '\n' || bidi_it->ch == BIDI_EOB || bidi_it->ch == '\n' || bidi_it->ch == BIDI_EOB
|| ((bidi_it->orig_type == NEUTRAL_WS || ((bidi_it->orig_type == NEUTRAL_WS
|| bidi_it->orig_type == WEAK_BN || bidi_it->orig_type == WEAK_BN /* L1/Retaining */
|| bidi_isolate_fmt_char (bidi_it->orig_type) || bidi_isolate_fmt_char (bidi_it->orig_type)
|| bidi_explicit_dir_char (bidi_it->ch)) || bidi_explicit_dir_char (bidi_it->ch))
&& (bidi_it->next_for_ws.type == NEUTRAL_B && (bidi_it->next_for_ws.type == NEUTRAL_B