[vim/vim] `E93: More than one match` when `<C-d>` shows only one match (Issue #13894)

23 views
Skip to first unread message

irisjae

unread,
Jan 20, 2024, 11:48:20 PMJan 20
to vim/vim, Subscribed

Steps to reproduce

Create the following file structure

mkdir test-vim-1
cd test-vim-1

mkdir -p src/app/jargon/views/
mkdir -p src/app/jargon/views/ProfileEditBottomSheetView/
mkdir -p src/app/jargon/views/ProfileEditBottomSheetView/
mkdir -p src/app/jargon/views/CheckInBottomSheetView/
mkdir -p src/app/jargon/views/pages/my-account/
mkdir -p src/app/jargon/views/ProfileEditBottomSheetView/
mkdir -p src/app/jargon/views/pages/home/
mkdir -p src/app/jargon/views/LanguagesBottomSheetView/
mkdir -p src/app/jargon/views/pages/coffee-house-detail/
mkdir -p src/app/jargon/views/
mkdir -p src/app/jargon/views/pages/chat/
mkdir -p src/app/jargon/views/pages/coffee-house-detail/
touch src/app/jargon/views/ShareWithFriendsBottomSheetView.js 
touch src/app/jargon/views/ProfileEditBottomSheetView/ProfileEditBottomSheetView.js 
touch src/app/jargon/views/ProfileEditBottomSheetView/ProfileImageControl.js 
touch src/app/jargon/views/CheckInBottomSheetView/CheckInBottomSheetView.js 
touch src/app/jargon/views/pages/my-account/OptionsMenuBottomSheetView.js 
touch src/app/jargon/views/ProfileEditBottomSheetView/profile-edit-bottom-sheet-view-terms.js 
touch src/app/jargon/views/pages/home/CoffeeHouseSearchBottomSheetView.js 
touch src/app/jargon/views/LanguagesBottomSheetView/LanguagesBottomSheetView.js 
touch src/app/jargon/views/pages/coffee-house-detail/ViewMemberBottomSheetView.js 
touch src/app/jargon/views/BottomSheetLayout.js 
touch src/app/jargon/views/pages/chat/AllReactionsBottomSheetView.js 
touch src/app/jargon/views/pages/coffee-house-detail/AddAdminBottomSheetView.js

Now, open vim, and open all the files (replace with your $PWD or test-vim-1):
:e /<path-to-dir>/src/app/jargon/views/ShareWithFriendsBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/ProfileEditBottomSheetView/ProfileEditBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/ProfileEditBottomSheetView/ProfileImageControl.js | e /<path-to-dir>/src/app/jargon/views/CheckInBottomSheetView/CheckInBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/pages/my-account/OptionsMenuBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/ProfileEditBottomSheetView/profile-edit-bottom-sheet-view-terms.js | e /<path-to-dir>/src/app/jargon/views/pages/home/CoffeeHouseSearchBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/LanguagesBottomSheetView/LanguagesBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/pages/coffee-house-detail/ViewMemberBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/BottomSheetLayout.js | e /<path-to-dir>/src/app/jargon/views/pages/chat/AllReactionsBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/pages/coffee-house-detail/AddAdminBottomSheetView.js

Finally, now type : b Bot, and <C-d> will somehow only produce src/app/jargon/views/BottomSheetLayout.js even though every other buffer contains the substring "Bot", and pressing Enter will produce the E93: More than one match.

Expected behaviour

: b Bot, and <C-d> should produce all the other loaded buffers. When <C-d> shows a single file, executing the command should not produce E93: More than one match.

Version of Vim

Tested on NixOS with "VIM - Vi IMproved 9.0", "Included patches: 1-1441" and macOS with "VIM - Vi IMproved 8.2)", "Included patches: 1-5032"

Environment

NixOS with "VIM - Vi IMproved 9.0", "Included patches: 1-1441"
TERM: xterm
shell: GNU bash, version 5.2.15(1)-release

macOS with "VIM - Vi IMproved 8.2)", "Included patches: 1-5032"
TERM: xterm-kitty
shell: zsh 5.8.1 (x86_64-apple-darwin21.0)

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/13894@github.com>

Christian Brabandt

unread,
Feb 21, 2024, 3:37:18 PMFeb 21
to vim/vim, Subscribed

I see what is happening. The buflist_findpat() function tries very hard to find a match. There are several tries:

  • just the pattern
  • pattern anchored to the beginning of the name (by prefixing with a ^)
  • pattern anchored to the end of the name (by adding a $)
  • pattern anchored to the beginning and and of the name (by prefixing a ^ and adding a $)

Now your pattern Bot already matches in the first round already those 2 files:

  • AddAdminBottomSheetView.js and
  • AllReactionsBottomSheetView.js

So it errors out.

However :h c_Ctrl-D uses command line completion (for the :b command it uses buffer-expansion) and explicitly anchors the pattern to the beginning of the file-name, so that only BottomSheetLayout.js is matched.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/13894/1957866940@github.com>

irisjae

unread,
Feb 22, 2024, 2:08:42 AMFeb 22
to vim/vim, Subscribed

<C-d> doesn't just search for the pattern at the beginning though; e.g. with the above test case, : b Adm followed by <C-d> returns AddAdminBottomSheetView.js just fine.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/13894/1958831479@github.com>

D. Ben Knoble

unread,
Feb 22, 2024, 12:30:56 PMFeb 22
to vim/vim, Subscribed

I agree; I’m confident (away from my computer) that C-d can complete from inner text of the buffer name.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/13894/1959928264@github.com>

Christian Brabandt

unread,
Feb 22, 2024, 2:25:49 PMFeb 22
to vim/vim, Subscribed

Yes that is correct. I found the issue then. Basically, the buffer expansion function tries to anchor the match against the start of word and only if it did not find a match yet tries again to match anywhere: https://github.com/vim/vim/blob/2a65e739447949a7aee966ce8a3b75521b2a79ea/src/buffer.c#L2813-L2814

So how about the following pach:

diff --git a/src/buffer.c b/src/buffer.c
index 4a39329c5..09938529a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2934,11 +2934,10 @@ ExpandBufnames(
        }

        if (!fuzzy)
-       {
            vim_regfree(regmatch.regprog);
-           if (count)          // match(es) found, break here
-               break;
-       }
+       // don't break here even when a match was found,
+       // we want to collect all matches, so continue
+       // matching anywhere in the buffer name
     }

     if (!fuzzy && patc != pat)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/13894/1960106488@github.com>

Christian Brabandt

unread,
Feb 24, 2024, 4:04:21 AMFeb 24
to vim/vim, Subscribed

I created #14082 for the fix


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/13894/1962304600@github.com>

Christian Brabandt

unread,
Feb 24, 2024, 8:19:08 AMFeb 24
to vim/vim, Subscribed

Closed #13894 as completed via 0dc0bff.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/13894/issue_event/11910798073@github.com>

Reply all
Reply to author
Forward
0 new messages