| Ticket UUID: | 5d983ebf4865037ed85ad5b43e567c5485edc2dc | |||||||||||||||||||||||||||
| Title: | Text widget: RTL auto-detection makes mapping and editing slow | |||||||||||||||||||||||||||
| Type: | Bug | Version: | 9.1b1 | |||||||||||||||||||||||||
| Submitter: | serhiy.storchaka | Created on: | 2026-09-24 10:46:49 | |||||||||||||||||||||||||
| Subsystem: | 18. [text] | Assigned To: | nobody | |||||||||||||||||||||||||
| Priority: | 5 Medium | Severity: | Important | |||||||||||||||||||||||||
| Status: | Closed | Last Modified: | 2026-10-13 04:14:18 | |||||||||||||||||||||||||
| Resolution: | Fixed | Closed By: | nab | |||||||||||||||||||||||||
| Closed on: | 2026-10-13 04:14:18 | |||||||||||||||||||||||||||
| Description: |
Since [8ce823d20c] (merge of rtl_text) the Text class bindings scan every line of the text in Tcl ( Mapping 900 text widgets with 300 lines each takes 2.1 s instead of 54 ms (9.0.5); a single text with 100000 lines takes about 1.3 s to map. Two more problems in the same code:
Only 9.1 is affected. This is a different problem from [1348333fff]. | |||||||||||||||||||||||||||
| User Comments: |
nab added on 2026-10-13 04:14:18:
Merged into trunk, [3a6ffd3b98|3a6ffd3b98]. Kevin Walzer, who wrote the RTL auto-detection, gave his green light. Thanks Serhiy for combining the two branches. nab added on 2026-10-12 14:21:53: Hi, it would be very nice to have this one on trunk. many thanks, nicolas serhiy.storchaka added on 2026-10-08 14:10:34: Combined with Nicolas's nab-text-rtl-scan (from [3d6de81648]) in branch text-rtl-detection, [c47ce655fd]:
Tests text-46.1 to 46.6 and textTag-19.1 to 19.5 (the duplicates of text-46.2 and 46.3 removed). They pass on X11 and Windows. A keystroke in 10000 lines takes 2 ms (Latin), 15 ms (Hebrew) and 8 ms (mixed), instead of 150, 79 and 71 ms on main (X11). serhiy.storchaka added on 2026-09-29 07:58:21: Attached a sample script. Results on Linux/X11 (Xvfb):
serhiy.storchaka added on 2026-09-24 11:11:59:
Fix on text-rtl-detect-speed: skip the scan if the text contains no RTL characters, remove the tag once instead of line by line, and check lines with regular expressions. The pending and auto-detection flags are now per widget and are removed on RTL characters now include all characters with Unicode Bidi_Class R or AL (Unicode 18): besides U+0590–U+08FF, also U+200F, the Hebrew and Arabic presentation forms, and U+10800–U+10FFF and U+1E800–U+1EFFF (e.g. Adlam). Mapping 900 text widgets with 300 lines now takes 48 ms instead of 2.1 s. A keystroke in a 5000-line Hebrew text takes 12 ms instead of 30 ms: text with RTL characters is still rescanned in full after each insert. A more complete fix would rescan only the changed lines; this is left for a follow-up. | |||||||||||||||||||||||||||
Attachments:
- 5d983ebf48_sample.tcl [download] added by serhiy.storchaka on 2026-09-29 07:56:13. [details]
