• R/O
  • SSH

vim: 提交

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

修訂875bd7c04533350c2d64e9fa3ce87ae0cf8a7891 (tree)
時間2020-10-30 03:00:04
作者Bram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 8.2.1921: fuzzy matching does not recognize path separators

Commit: https://github.com/vim/vim/commit/dcdd42a8ccb9bafd857735d694b074269f337333
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 29 18:58:01 2020 +0100

patch 8.2.1921: fuzzy matching does not recognize path separators
Problem: Fuzzy matching does not recognize path separators.
Solution: Add a bonus for slash and backslash. (Yegappan Lakshmanan,
closes #7225)

Change Summary

差異

diff -r 34e09ca2ddb7 -r 875bd7c04533 src/search.c
--- a/src/search.c Wed Oct 28 23:00:05 2020 +0100
+++ b/src/search.c Thu Oct 29 19:00:04 2020 +0100
@@ -4258,8 +4258,10 @@
42584258 // bonus for adjacent matches; this is higher than SEPARATOR_BONUS so that
42594259 // matching a whole word is preferred.
42604260 #define SEQUENTIAL_BONUS 40
4261-// bonus if match occurs after a separator
4262-#define SEPARATOR_BONUS 30
4261+// bonus if match occurs after a path separator
4262+#define PATH_SEPARATOR_BONUS 30
4263+// bonus if match occurs after a word separator
4264+#define WORD_SEPARATOR_BONUS 25
42634265 // bonus if match is uppercase and prev is lower
42644266 #define CAMEL_BONUS 30
42654267 // bonus if the first letter is matched
@@ -4334,7 +4336,6 @@
43344336 // Camel case
43354337 int neighbor = ' ';
43364338 int curr;
4337- int neighborSeparator;
43384339
43394340 if (has_mbyte)
43404341 {
@@ -4355,10 +4356,11 @@
43554356 if (vim_islower(neighbor) && vim_isupper(curr))
43564357 score += CAMEL_BONUS;
43574358
4358- // Separator
4359- neighborSeparator = neighbor == '_' || neighbor == ' ';
4360- if (neighborSeparator)
4361- score += SEPARATOR_BONUS;
4359+ // Bonus if the match follows a separator character
4360+ if (neighbor == '/' || neighbor == '\\')
4361+ score += PATH_SEPARATOR_BONUS;
4362+ else if (neighbor == ' ' || neighbor == '_')
4363+ score += WORD_SEPARATOR_BONUS;
43624364 }
43634365 else
43644366 {
diff -r 34e09ca2ddb7 -r 875bd7c04533 src/testdir/test_matchfuzzy.vim
--- a/src/testdir/test_matchfuzzy.vim Wed Oct 28 23:00:05 2020 +0100
+++ b/src/testdir/test_matchfuzzy.vim Thu Oct 29 19:00:04 2020 +0100
@@ -43,6 +43,8 @@
4343 call assert_equal(['.vim/vimrc', '.vim/vimrc_colors', '.vim/v_i_m_r_c'], ['.vim/vimrc', '.vim/vimrc_colors', '.vim/v_i_m_r_c']->matchfuzzy('vimrc'))
4444 " gap penalty
4545 call assert_equal(['xxayybxxxx', 'xxayyybxxx', 'xxayyyybxx'], ['xxayyyybxx', 'xxayyybxxx', 'xxayybxxxx']->matchfuzzy('ab'))
46+ " path separator vs word separator
47+ call assert_equal(['color/setup.vim', 'color\\setup.vim', 'color setup.vim', 'color_setup.vim', 'colorsetup.vim'], matchfuzzy(['colorsetup.vim', 'color setup.vim', 'color/setup.vim', 'color_setup.vim', 'color\\setup.vim'], 'setup.vim'))
4648
4749 " match multiple words (separated by space)
4850 call assert_equal(['foo bar baz'], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzy('baz foo'))
diff -r 34e09ca2ddb7 -r 875bd7c04533 src/version.c
--- a/src/version.c Wed Oct 28 23:00:05 2020 +0100
+++ b/src/version.c Thu Oct 29 19:00:04 2020 +0100
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1921,
755+/**/
754756 1920,
755757 /**/
756758 1919,
Show on old repository browser