To: vim_dev@googlegroups.com Subject: Patch 8.2.1921 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1921 Problem: Fuzzy matching does not recognize path separators. Solution: Add a bonus for slash and backslash. (Yegappan Lakshmanan, closes #7225) Files: src/search.c, src/testdir/test_matchfuzzy.vim *** ../vim-8.2.1920/src/search.c 2020-10-24 20:49:37.502683026 +0200 --- src/search.c 2020-10-29 18:55:45.136014590 +0100 *************** *** 4258,4265 **** // bonus for adjacent matches; this is higher than SEPARATOR_BONUS so that // matching a whole word is preferred. #define SEQUENTIAL_BONUS 40 ! // bonus if match occurs after a separator ! #define SEPARATOR_BONUS 30 // bonus if match is uppercase and prev is lower #define CAMEL_BONUS 30 // bonus if the first letter is matched --- 4258,4267 ---- // bonus for adjacent matches; this is higher than SEPARATOR_BONUS so that // matching a whole word is preferred. #define SEQUENTIAL_BONUS 40 ! // bonus if match occurs after a path separator ! #define PATH_SEPARATOR_BONUS 30 ! // bonus if match occurs after a word separator ! #define WORD_SEPARATOR_BONUS 25 // bonus if match is uppercase and prev is lower #define CAMEL_BONUS 30 // bonus if the first letter is matched *************** *** 4334,4340 **** // Camel case int neighbor = ' '; int curr; - int neighborSeparator; if (has_mbyte) { --- 4336,4341 ---- *************** *** 4355,4364 **** if (vim_islower(neighbor) && vim_isupper(curr)) score += CAMEL_BONUS; ! // Separator ! neighborSeparator = neighbor == '_' || neighbor == ' '; ! if (neighborSeparator) ! score += SEPARATOR_BONUS; } else { --- 4356,4366 ---- if (vim_islower(neighbor) && vim_isupper(curr)) score += CAMEL_BONUS; ! // Bonus if the match follows a separator character ! if (neighbor == '/' || neighbor == '\\') ! score += PATH_SEPARATOR_BONUS; ! else if (neighbor == ' ' || neighbor == '_') ! score += WORD_SEPARATOR_BONUS; } else { *** ../vim-8.2.1920/src/testdir/test_matchfuzzy.vim 2020-10-23 16:49:30.116311438 +0200 --- src/testdir/test_matchfuzzy.vim 2020-10-29 18:55:45.136014590 +0100 *************** *** 43,48 **** --- 43,50 ---- 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')) " gap penalty call assert_equal(['xxayybxxxx', 'xxayyybxxx', 'xxayyyybxx'], ['xxayyyybxx', 'xxayyybxxx', 'xxayybxxxx']->matchfuzzy('ab')) + " path separator vs word separator + 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')) " match multiple words (separated by space) call assert_equal(['foo bar baz'], ['foo bar baz', 'foo', 'foo bar', 'baz bar']->matchfuzzy('baz foo')) *** ../vim-8.2.1920/src/version.c 2020-10-28 22:46:38.914990895 +0100 --- src/version.c 2020-10-29 18:56:59.511867769 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1921, /**/ -- hundred-and-one symptoms of being an internet addict: 148. You find it easier to dial-up the National Weather Service Weather/your_town/now.html than to simply look out the window. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///