Revised [text]: assertion failed in tkTextDisp.c:7191

Happens in TkTextUpdateLineMetrics():
<verbatim>
    assert(lineNum <= endLine);
</verbatim>

Breakpointing at this place just before the assertion, one gets the following call stack:
<verbatim>
>	tk87tg.dll!TkTextUpdateLineMetrics(TkText * textPtr=0x03498e40, unsigned int lineNum=106, unsigned int endLine=106)

 Line 7192	C
 	tk87tg.dll!UpdateLineMetrics(TkText * textPtr=0x03498e40, unsigned int startLine=106, unsigned int endLine=106)

Line 1253 + 0x11 bytes	C
 	tk87tg.dll!TextWidgetObjCmd(void * clientData=0x03498e40, Tcl_Interp * interp=0x006e2270, int objc=6, Tcl_Obj *

const * objv=0x006e6728)  Line 1873 + 0x17 bytes	C
 	tcl87tg.dll!Dispatch(void * * data=0x03bf62cc, Tcl_Interp * interp=0x006e2270, int result=0)  Line 4376 + 0x15

bytes	C
 	tcl87tg.dll!TclNRRunCallbacks(Tcl_Interp * interp=0x006e2270, int result=0, NRE_callback * rootPtr=0x00000000)

Line 4409 + 0x14 bytes	C
 	tcl87tg.dll!Tcl_EvalObjv(Tcl_Interp * interp=0x006e2270, int objc=3, Tcl_Obj * const * objv=0x006e64d0, int

flags=2097168)  Line 4139 + 0x11 bytes	C
 	tcl87tg.dll!TclEvalEx(Tcl_Interp * interp=0x006e2270, const char * script=0x034e3a40, int numBytes=109, int

flags=131072, int line=1, int * clNextOuter=0x00000000, const char * outerScript=0x034e3a40)  Line 5279 + 0x16 bytes	C
 	tcl87tg.dll!Tcl_EvalEx(Tcl_Interp * interp=0x006e2270, const char * script=0x034e3a40, int numBytes=109, int

flags=131072)  Line 4943 + 0x1d bytes	C
 	tk87tg.dll!Tk_BindEvent(Tk_BindingTable_ * bindPtr=0x00730378, _XEvent * eventPtr=0x032e8858, Tk_Window_ *

tkwin=0x0337a5a0, int numObjects=0, void * * objectPtr=0x002bfb84)  Line 1505 + 0x27 bytes	C
 	tk87tg.dll!TkBindEventProc(TkWindow * winPtr=0x0337a5a0, _XEvent * eventPtr=0x032e8858)  Line 317 + 0x1f bytes	C
 	tk87tg.dll!Tk_HandleEvent(_XEvent * eventPtr=0x032e8858)  Line 1374 + 0xd bytes	C
 	tk87tg.dll!WindowEventProc(Tcl_Event * evPtr=0x032e8850, int flags=-3)  Line 1764 + 0xc bytes	C
 	tcl87tg.dll!Tcl_ServiceEvent(int flags=-3)  Line 670 + 0xd bytes	C
 	tcl87tg.dll!Tcl_DoOneEvent(int flags=-3)  Line 967 + 0x9 bytes	C
 	tk87tg.dll!Tk_MainLoop()  Line 2148 + 0x11 bytes	C
 	tk87tg.dll!Tk_MainExW(int argc=-1, unsigned short * * argv=0x003b32d8, int (Tcl_Interp *)* appInitProc=0x004010e0,

Tcl_Interp * interp=0x006e2270)  Line 391	C
 	wish87tg.exe!wWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, unsigned short *

lpszCmdLine=0x006a16b6, int nCmdShow=10)  Line 150 + 0x39 bytes	C
 	wish87tg.exe!__tmainCRTStartup()  Line 574 + 0x35 bytes	C
 	wish87tg.exe!wWinMainCRTStartup()  Line 399	C
 	kernel32.dll!7642f964()
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
 	ntdll.dll!7703e369()
 	ntdll.dll!7703e57b()
</verbatim>

This shows that the command currently executed was ".text count -update -ypixels", with the "indexFrom" and "indexTo" being identical, which triggers the assertion.

The call to:
<verbatim>
    UpdateLineMetrics(textPtr, from, to);
</verbatim>
in tkText.c:1873 surely does not need to be done  if (indexFrom == indexTo)

Perhaps adding this test would be enough to fix the issue.

This is fully repeatable in my application. I can try to produce a short demo script if needed.