Skip to content
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

Duplicate match dialog upon improper use of extends keyword in snippets #1559

Open
kkew3 opened this issue Oct 9, 2024 · 1 comment
Open

Comments

@kkew3
Copy link

kkew3 commented Oct 9, 2024

This issue is related to #1519, but in a reproducible way.

In my context, I collect all math-related snippets in a file called tex_math.snippets, and I have a tex.snippets with content:

extends tex_math.snippets

# Some LaTeX-specific snippets

The issue occurs when I type any snippet in a a.tex file that is defined in tex_math.snippets, something like:

1: (frac) "math frac" (/Users/user/.vim/UltiSnips/tex_math.snippets:1)
2: (frac) "math frac" (/Users/user/.vim/UltiSnips/tex_math.snippets:1)

The cause of the issue is that according to UltiSnips doc (section UltiSnips-how-snippets-are-loaded), both tex_math.snippets and tex.snippets refer to snippets of tex filetype. Thus, by extending tex_math.snippets in tex.snippets, it might somehow trigger certain naming conflicts and causes any snippet defined in tex_math.snippets to be redefined. Interestingly, using extends tex rather than extends tex_math in tex.snippets won't trigger the issue.

Expected behavior:

Either error out, suggesting the user extends tex_math is an improper use of extends keyword, or behave as if the extends tex_math in tex.snippets is not present. In the latter case, all definitions in tex_math.snippets take effect in a a.tex file automatically, by definition.

Actual behavior:

As mentioned above, something like

1: (frac) "math frac" (/Users/user/.vim/UltiSnips/tex_math.snippets:1)
2: (frac) "math frac" (/Users/user/.vim/UltiSnips/tex_math.snippets:1)

is prompted, and the user must enter, e.g. 1<ENTER>, to select one, which IMHO is confusing and misleading.

Steps to reproduce

In the docker container:

  1. Open vim x.tex
  2. Type frac<TAB>
  3. The prompt mentioned above occurs

  • Operating System: macOS 12.7.6
  • Vim Version:
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan  4 2024 03:08:50)
macOS version - x86_64
  • UltiSnips Version: 49dc8cb
  • Python inside Vim:

py:

2.7.18 (v2.7.18:8d21aa21f2, Apr 19 2020, 20:48:48)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

py3:

3.11.9 (v3.11.9:de54cf5be3, Apr  2 2024, 07:12:50) [Clang 13.0.0 (clang-1300.0.29.30)]
@kkew3
Copy link
Author

kkew3 commented Oct 9, 2024

It seems that under vim 9, set nocompatible needs be added to vimrc to reproduce the issue, whereas under vim 8 (in the docker environment), it's not necessary. That's why I didn't include this line in https://github.com/kkew3/ultisnips-issue1/blob/issue/docker/docker_vimrc.vim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant