Skip to content

Conversation

@zeertzjq
Copy link
Member

@zeertzjq zeertzjq commented Oct 9, 2023

vim-patch:9.0.2009: cmdline-completion for comma-separated options wrong

Problem: cmdline-completion for comma-separated options wrong
Solution: Fix command-line expansions for options with filenames with
commas

Fix command-line expansions for options with filenames with commas

Cmdline expansion for option values that take a comma-separated list
of file names is currently not handling file names with commas as the
commas are not escaped. For such options, the commas in file names need
to be escaped (to differentiate from a comma that delimit the list
items). The escaped comma is unescaped in copy_option_part() during
option parsing.

Fix as follows:

  • Cmdline completion for option values with comma-separated file/folder
    names will not start a new match when seeing \\, and will instead
    consider it as one value.
  • File/folder regex matching will strip the \\ when seeing \\, to
    make sure it can match the correct files/folders.
  • The expanded value will escape , with \\,, similar to how spaces
    are escaped to make sure the option value is correct on the cmdline.

This fix also takes into account the fact that Win32 Vim handles file
name escaping differently. Typing ',' for a file name results in it
being handled literally but in other platforms ',' is interpreted as a
simple ',' and commas need to be escaped using '\,' instead.

Also, make sure this new logic only applies to comma-separated options
like 'path'. Non-list options like 'set makeprg=' and regular ex
commands like :edit <Tab> do not require escaping and will continue to
work.

Also fix up documentation to be clearer. The original docs are slightly
misleading in how it discusses triple slashes for 'tags'.

closes: vim/vim#13303
related: vim/vim#13301

vim/vim@5484485

Co-authored-by: Yee Cheng Chin [email protected]

@zeertzjq zeertzjq changed the title vim-patch:9.0.2009 vim-patch:9.0.2009: cmdline-completion for comma-separated options wrong Oct 9, 2023
@github-actions github-actions bot added the vim-patch See https://neovim.io/doc/user/dev_vimpatch.html label Oct 9, 2023
@github-actions github-actions bot requested a review from seandewar October 9, 2023 22:54
Problem:  cmdline-completion for comma-separated options wrong
Solution: Fix command-line expansions for options with filenames with
          commas

Fix command-line expansions for options with filenames with commas

Cmdline expansion for option values that take a comma-separated list
of file names is currently not handling file names with commas as the
commas are not escaped. For such options, the commas in file names need
to be escaped (to differentiate from a comma that delimit the list
items). The escaped comma is unescaped in `copy_option_part()` during
option parsing.

Fix as follows:
- Cmdline completion for option values with comma-separated file/folder
  names will not start a new match when seeing `\\,` and will instead
  consider it as one value.
- File/folder regex matching will strip the `\\` when seeing `\\,` to
  make sure it can match the correct files/folders.
- The expanded value will escape `,` with `\\,`, similar to how spaces
  are escaped to make sure the option value is correct on the cmdline.

This fix also takes into account the fact that Win32 Vim handles file
name escaping differently. Typing '\,' for a file name results in it
being handled literally but in other platforms '\,' is interpreted as a
simple ',' and commas need to be escaped using '\\,' instead.

Also, make sure this new logic only applies to comma-separated options
like 'path'. Non-list options like 'set makeprg=<Tab>' and regular ex
commands like `:edit <Tab>` do not require escaping and will continue to
work.

Also fix up documentation to be clearer. The original docs are slightly
misleading in how it discusses triple slashes for 'tags'.

closes: vim/vim#13303
related: vim/vim#13301

vim/vim@5484485

Co-authored-by: Yee Cheng Chin <[email protected]>
@zeertzjq zeertzjq merged commit c40a1c0 into neovim:master Oct 10, 2023
@zeertzjq zeertzjq deleted the vim-9.0.2009 branch October 10, 2023 01:15
@github-actions github-actions bot removed the request for review from seandewar October 10, 2023 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vim-patch See https://neovim.io/doc/user/dev_vimpatch.html

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant