Yakov Lerner wrote: > inoremap <expr><F2> PeekCharTimeout(1000)?"you pressed key! ":"timeout! " > > I hit a case when getchar(1) seemingly consumes a pressed key. > > 1. vim -u NONE -c 'so x.vim' # file x.vim is below > 2. If you press i<F2> and wait, you get 'timeout!', so this part works OK. > 3. The other branch, has problem: press i<F2> then quickly 123. You get: > you pressed key! 23 > Note that '1' gets lost. We expect result 'you pressed key! 123' > Since I call only getchar(1) here I don't understand why one pressed > char gets lost.
It's not the getchar() that eats the typed character, it's because anything that is typed while the expression mapping is busy goes into nothingness. You are using an input function while inside the input stuff, that doesn't work very well. I'm glad Vim didn't crash. -- "Microsoft is like Coke. It's a secret formula, all the money is from distribution, and their goal is to get Coke everywhere. Open source is like selling water. There are water companies like Perrier and Poland Spring, but you're competing with something that's free." -- Carl Howe /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
