Bugs in Display Logic

The display logic has bugs (version 8.6), try this example:

This is the result:

wish8.6 revised version

The result in left text widget is obviously wrong, the revised version gives the correct result (in right widget).

The following script is even crashing, although this requires that debug mode is enabled:

Also the display of insert cursor has problems (version 8.6) when elided ranges are involved, try this example:

The cursor should be visible at first character, but isn't visible. If you move the insert cursor to right, it will appear (at second character), and then move left two times, it will disappear again.

These are good examples that the implementation of the -elide feature in wish8.6 has severe problems – all these ugly hacks, and so many reported bugs – but in revised version this feature has been re-implemented in a proper way (but this feature still requires special handling at several places, and this is always problematic – meaning error-prone).

One more bug: after executing this script you will see an empty text widget (tested with X11):

But after pressing any cursor key (left or right) the text content will re-appear. (Hint: TkTextFindDisplayLineStartEnd is returning a byte position inside the two-byte sequence "ΓΌ" when searching for end of the display line, and this is destroying the UTF-8 string.)

Try next example:

The revised version will show the insert cursor, but not wish8.6. Click with mouse only a few pixels right from character "4", and the insert cursor will be shown, but if you click near the right border at last line the insert cursor will disappear again.

This script is hanging, tested with X11 (although this is only a minor bug, nobody is doing such weird things like in this script):