http://bugs.winehq.org/show_bug.cgi?id=13188
--- Comment #6 from Yu-Ning Feng fengyuning1984@gmail.com 2008-05-16 03:02:15 --- (In reply to comment #1)
After some effort debugging, I found this bug to be a sync problem.
kd runs in 2 threads. WriteConsole[AW] and ReadConsoleW are in different threads. Most of the time, CONSOLE_Readline is called before a series of WriteConsole[AW]. When CONSOLE_Readline is waiting for input at
809 while (!ctx.done && !ctx.error && WCEL_Get(&ctx, &ir))
it will be swapped out, and WriteConsole[AW] is swapped in, updates the window by some output. When CONSOLE_Readline is swapped in again, the ctx is already outdated, causing the echo be at a wrong place.
A solution could be to add a GetConsoleScreenBufferInfo between
809 while (!ctx.done && !ctx.error && WCEL_Get(&ctx, &ir))
and
854 SetConsoleCursorPosition(ctx.hConOut, WCEL_GetCoord(&ctx, ctx.ofs));
As not involved in developing, the solution may be not elegant. With the reason discovered, however, a proper solution should be easy to get.
Really looking forward to the bug being resolved in the coming release.