Skip to content

Spurious " appears on the command-line when setcmdpos() is invoked #9917

@lacygoill

Description

@lacygoill
  • nvim --version: NVIM v0.4.0-610-g773bdd41e Build type: RelWithDebInfo
  • Vim (version: 8.1-1176) behaves differently? Yes, no undesired quotation mark on Vim's command-line.
  • Operating system: Ubuntu 16.04.6 LTS
  • Terminal emulator: rxvt-unicode v9.22
  • Terminal multiplexer: tmux 2.9
  • $TERM: tmux-256color
  • Shell: zsh 5.7.1-dev-0 (x86_64-pc-linux-gnu)

Steps to reproduce using nvim -u NORC

Consider this shell command:

$ nvim -Nu NONE +'nno cd :tabe $MYVIMRC<c-r>=setcmdpos(14)[-1]<cr>'

It installs a mapping, triggered by the sequence cd, wich populates the command-line with :tabe $MYVIMRC and positions the cursor to the 14th byte.

Actual behaviour

If you press cd, the command-line is populated with:

:tabe $MYVIMRC"
              ^

Note the quotation mark at the end. It's drawn on the command-line, but I don't think it's really there; if it was, the mapping would fail to edit the init.vim file after pressing Enter (provided you started Nvim without -Nu NONE).

I bisected the issue to 3b7a4f2.

The example given here is contrived, because you don't need <c-r>=setcmdpos(n)[-1]. But I do in a plugin where I install a key binding which cycles through a set of arbitrary commands to populate the command-line. I need something like <c-r>=setcmdpos(stridx(cmdline, special_char))[-1].

Every time the command-line is populated by a command, there's a spurious quotation mark somewhere in the middle or at the end.

MPdvU4W

And if you move the cursor, it gets worse, you can have multiple quotation marks anywhere.

gif

Expected behaviour

No spurious quotation mark on the command-line after invoking setcmdpos() through the expression register to set the position of the cursor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-regressionwrong behavior that was introduced in a previous commit (please bisect)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions