Bug#608242: :set nocompatible, vim -w or -W records extra garbage keystrokes

Josh Triplett josh at joshtriplett.org
Wed Dec 29 09:26:25 UTC 2010


Package: vim
Version: 2:7.3.035+hg~8fdc12103333-1
Severity: normal

I think I've tracked down the root cause of this bug.

- Vim asks the terminal for its version string when it starts, in the
  may_req_termresponse function, by sending the kPRV string from the
  terminfo record, and then calling vpeekc_nomap.

- That reads the response from stdin into typebuf, and eventually ends
  up in check_termcode, which handles terminal escape sequences.

- check_termcode finds the version response, and if it manages to
  extract an xterm version number, it sets various features based on
  that version number.

- check_termcode then translates the escape sequence into the key_name
  array as KS_EXTRA and KE_IGNORE, which match the second and third
  bytes of the escape sequence.

- Towards the end of check_termcode (near the comment "Add any modifier
  codes to our string."), this becomes a three-byte sequence K_SPECIAL
  KS_EXTRA KE_IGNORE, which matches the three bytes that appear in the
  script file.

- check_termcode then puts this sequence into the typebuf, and doesn't
  seem to set anything to make vim treat this sequence as something not
  typed by the user.

- Later on, this character gets read, and ends up in vgetorpeek.  Near
  the comment "get a character: 2. from the typeahead buffer",
  vgetorpeek ends up considering this character a typed character, and
  feeds it to gotchars, which calls updatescript on each character to
  write it to the script file.


I don't know the correct fix.  Possibly something should set tb_maplen
to mark the character as the result of a map, or possibly the character
shouldn't get re-inserted into typebuf at all.

- Josh Triplett


-- System Information:
Debian Release: 6.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.37-rc5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages vim depends on:
ii  libacl1      2.2.49-4                    Access control list shared library
ii  libc6        2.11.2-7                    Embedded GNU C Library: Shared lib
ii  libgpm2      1.20.4-3.3                  General Purpose Mouse - shared lib
ii  libncurses5  5.7+20100313-4              shared libraries for terminal hand
ii  libselinux1  2.0.96-1                    SELinux runtime shared libraries
ii  vim-common   2:7.3.035+hg~8fdc12103333-1 Vi IMproved - Common files
ii  vim-runtime  2:7.3.035+hg~8fdc12103333-1 Vi IMproved - Runtime files

vim recommends no packages.

Versions of packages vim suggests:
pn  ctags                         <none>     (no description available)
pn  vim-doc                       <none>     (no description available)
pn  vim-scripts                   <none>     (no description available)

-- no debconf information





More information about the pkg-vim-maintainers mailing list