charliesome/better_errors — pull request #218 by HeeL (2013-11-23 23:16:34+00:00)
Title: move the cursor to the end of the input when navigating through commands...

I fixed that unusual behavior when the user navigates through the history of previously executed commands. If user use the arrow up key then the cursor always jumps to the beginning of the input.
I found a line of code that was trying to fix that but it didn't work so I spend some time trying to figure out why. The reason was the default browser behavior that you can't prevent by simply returning from the onkeydown function.
Even though, my patch looks like a dirty hack, that's the only solution I found to make it work. Basically if you press arrow up in the text field, after all the code related to KeyDown event will be ran, the browser will move the cursor at the beginning of the string. So, the only solution I could apply is to wait a millisecond and move that cursor back to the end where it belongs.