-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropping Characters Waiting for Vim's Completion #23
Comments
I'm a little surprised this happens in SkyBison as this effect isn't triggered by these examples: noremap F :call TestChar2()<CR>
function! TestChar1()
let s = ""
while 1
let c = nr2char(getchar())
echo "Char: " . c
if c == "\r"
break
endif
let s .= c
sleep 1000m
endwhile
redraw
echom "Result: " . s
endfunction
function! TestChar2()
let s = ""
while 1
if getchar(1)
let c = nr2char(getchar())
echo "Char: " . c
if c == "\r"
break
endif
let s .= c
sleep 1000m
endif
endwhile
redraw
echom "Result: " . s
endfunction |
Could this (see comments) be the problem with function! TestChar1()
let s = ""
while 1
let c = getchar()
echo "Char #: " . c
" getchar() with newline is 13, but here newline is 10?????????
" :echo getchar()
if c == 10
break
endif
let c = nr2char(c)
echo "Char S: " . c
if c == "\r"
break
endif
let s .= c
sleep 1000m
endwhile
redraw
echom "Result: " . s
endfunction |
Not sure what order you'll view these in, so I'm going to prefix all of the I've got a skybison 2.0 ~90% done with many improvements. There's some I think the effect is not triggered in your examples because of how 2.0 completely reworks the input system - no more getchar() vs getchar(1) There's a number of work-arounds for this:
The last option would be, by far, the cleanest to implement, but it's also I wasn't planning on resolving this issue for the 2.0 release, but I could |
What about builtin hacky multithread/process stuff? Since I wasn't able to reproduce this effect as a test case, I don't know if this will work: function! GetChar()
python << EOF
import vim
import sys
vim.command("return '{}'".format(sys.stdin.read(1)))
EOF
endfunction |
I think vim disables all input buffering and appends received characters to the 'typeahead' buffer. This explains the difference between c's getchar() and vim's getchar(): the former is line-buffered. (Vim buffers function output, in the above code block a I couldn't duplicate the effect using Unfortunately python and vim share fo = os.fdopen(os.dup(sys.stdin.fileno())) Though probably python internally buffers |
Then I try reading from vim's stdin (not python's) and find that I unfortunately can't seek. It also turns out:
So I assume this must be a vim bug - it works in NeoVim, albeit slower. Best possible approach would be to get this fixed upstream. Any ideas on creating a simple test-case? |
Here's a simple test that should be easily repeatable on all but extremely fast hardware: Run this to start vim:
Enter insert mode then type "fj" relatively quickly. The "j" will be dropped while the processing for "f" is going. I'd be happy to submit it a bug report upstream myself once my blockers are out of the way. If you want to go for it now (while I'm otherwise unable to), you're more than welcome to use that example to illustrate the issue. I'd prefer you not mention skybison if you can avoid it - I don't want to draw more attention to this project while I'm in the awkward position where I can't update it. Just treat it as a generalized issue if you can. |
In either input modes, SkyBison drops characters while waiting for Vim's built-in command completion. I know this is a big requestion and may not be fixable. Its not the lag that is problematic, the fact that key-presses disappear. For example:
h catch
->h ctch
The text was updated successfully, but these errors were encountered: