summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2024-07-09 18:51:29 +0200
committerChristian Brabandt <cb@256bit.org>2024-07-09 18:51:29 +0200
commit600a12d08e7aeb95a6b02382bfee310aef9801dd (patch)
tree00394eae2f4a8cdbd2bb92de5c384d611ab936ab
parent7298565c85b8c32dce73d782aa44581419e1fa3f (diff)
patch 9.1.0549: fuzzycollect regex based completion not working as expectedv9.1.0549
Problem: fuzzycollect regex based completion not working as expected Solution: Revert Patch v9.1.0503 (glepnir) closes: #15192 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--runtime/doc/options.txt7
-rw-r--r--runtime/doc/version9.txt4
-rw-r--r--src/insexpand.c38
-rw-r--r--src/option.h1
-rw-r--r--src/optionstr.c2
-rw-r--r--src/testdir/test_ins_complete.vim31
-rw-r--r--src/version.c2
7 files changed, 6 insertions, 79 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index e9c94aa8e5..e28f185aa8 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt* For Vim version 9.1. Last change: 2024 Jul 06
+*options.txt* For Vim version 9.1. Last change: 2024 Jul 09
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2151,11 +2151,6 @@ A jump table for the options with a short description can be found at |Q_op|.
difference how completion candidates are reduced from the
list of alternatives, but not how the candidates are
collected (using different completion types).
- fuzzycollect
- Enable fuzzy collection for default keyword completion.
- This allows the collection of matches using fuzzy matching
- criteria, providing more comprehensive and flexible
- results. Works in combination with other fuzzy options.
*'completepopup'* *'cpp'*
'completepopup' 'cpp' string (default empty)
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 86ec0208ac..9cf20300fa 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41646,8 +41646,8 @@ Improved visual highlighting.
Python3 support in OpenVMS.
-Support for |fuzzy-matching| during |ins-completion| with the "fuzzy" and
-"fuzzycollect" values of the 'completeopt' setting
+Support for |fuzzy-matching| during |ins-completion| with the "fuzzy"
+values of the 'completeopt' setting
==============================================================================
COMPILE TIME CHANGES *compile-changes-9.2*
diff --git a/src/insexpand.c b/src/insexpand.c
index 36228e9b13..21b53d1e3e 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -4512,11 +4512,6 @@ ins_compl_use_match(int c)
static int
get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
{
- int i;
- int char_len;
- size_t fuzzy_len;
- char_u *fuzzy_pattern;
-
if ((compl_cont_status & CONT_SOL) || ctrl_x_mode_path_defines())
{
if (!compl_status_adding())
@@ -4630,39 +4625,6 @@ get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
}
compl_patternlen = STRLEN(compl_pattern);
-
- if ((get_cot_flags() & COT_FUZZYCOLLECT) != 0)
- {
- // Adjust size to avoid buffer overflow
- fuzzy_len = (size_t)compl_length * 5 + 10;
- // Allocate enough space
- fuzzy_pattern = alloc(fuzzy_len);
- if (fuzzy_pattern == NULL)
- {
- compl_patternlen = 0;
- return FAIL;
- }
- // Use 'very magic' mode for simpler syntax
- STRCPY(fuzzy_pattern, "\\v");
- i = 2; // Start from 2 to skip "\\v"
- while (i < compl_length + 2)
- {
- // Append "\\k*" before each character
- STRNCAT(fuzzy_pattern, "\\k*", fuzzy_len - STRLEN(fuzzy_pattern) - 1);
- // Get length of current multi-byte character
- char_len = mb_ptr2len(compl_pattern + i);
- // Concatenate the character safely
- STRNCAT(fuzzy_pattern, compl_pattern + i, char_len);
- // Move to the next character
- i += char_len;
- }
- // Append "\\k*" at the end to match any characters after the pattern
- STRNCAT(fuzzy_pattern, "\\k*", fuzzy_len - STRLEN(fuzzy_pattern) - 1);
- vim_free(compl_pattern);
- compl_pattern = fuzzy_pattern;
- compl_patternlen = STRLEN(compl_pattern);
- }
-
return OK;
}
diff --git a/src/option.h b/src/option.h
index 67d0b04620..630d7bf6b7 100644
--- a/src/option.h
+++ b/src/option.h
@@ -527,7 +527,6 @@ EXTERN unsigned cot_flags; // flags from 'completeopt'
#define COT_NOINSERT 0x040 // FALSE: select & insert, TRUE: noinsert
#define COT_NOSELECT 0x080 // FALSE: select & insert, TRUE: noselect
#define COT_FUZZY 0x100 // TRUE: fuzzy match enabled
-#define COT_FUZZYCOLLECT 0x200 // TRUE: fuzzy collect enabled
#ifdef BACKSLASH_IN_FILENAME
EXTERN char_u *p_csl; // 'completeslash'
#endif
diff --git a/src/optionstr.c b/src/optionstr.c
index 9adb77dff5..417f785907 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -118,7 +118,7 @@ static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
NULL};
static char *(p_fcl_values[]) = {"all", NULL};
#endif
-static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "popup", "popuphidden", "noinsert", "noselect", "fuzzy", "fuzzycollect", NULL};
+static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "popup", "popuphidden", "noinsert", "noselect", "fuzzy", NULL};
#ifdef BACKSLASH_IN_FILENAME
static char *(p_csl_values[]) = {"slash", "backslash", NULL};
#endif
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 61c8ac7643..48589ce188 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -2586,37 +2586,6 @@ func Test_complete_fuzzy_match()
call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
call assert_equal('hello help hero h', getline('.'))
- set completeopt=fuzzycollect
- call setline(1, ['xyz yxz x'])
- call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
- call assert_equal('xyz yxz xyz', getline('.'))
- " can fuzzy get yxz when use Ctrl-N twice
- call setline(1, ['xyz yxz x'])
- call feedkeys("A\<C-X>\<C-N>\<C-N>\<Esc>0", 'tx!')
- call assert_equal('xyz yxz yxz', getline('.'))
-
- call setline(1, ['one two o'])
- call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
- call assert_equal('one two one', getline('.'))
-
- call setline(1, ['你好 你'])
- call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
- call assert_equal('你好 你好', getline('.'))
- call setline(1, ['你的 我的 的'])
- call feedkeys("A\<C-X>\<C-N>\<Esc>0", 'tx!')
- call assert_equal('你的 我的 你的', getline('.'))
- " can fuzzy get multiple-byte word when use Ctrl-N twice
- call setline(1, ['你的 我的 的'])
- call feedkeys("A\<C-X>\<C-N>\<C-N>\<Esc>0", 'tx!')
- call assert_equal('你的 我的 我的', getline('.'))
-
- "respect noinsert
- set completeopt=fuzzycollect,menu,menuone,noinsert
- call setline(1, ['one two o'])
- call feedkeys("A\<C-X>\<C-N>", 'tx')
- call assert_equal('one', g:word)
- call assert_equal('one two o', getline('.'))
-
" clean up
set omnifunc=
bw!
diff --git a/src/version.c b/src/version.c
index 1f334caba2..dd5b254a07 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 549,
+/**/
548,
/**/
547,
='#n523'>523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211
/*
 *  linux/fs/pipe.c
 *
 *  Copyright (C) 1991, 1992, 1999  Linus Torvalds
 */

#include <linux/mm.h>
#include <linux/file.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/log2.h>
#include <linux/mount.h>
#include <linux/magic.h>
#include <linux/pipe_fs_i.h>
#include <linux/uio.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/audit.h>
#include <linux/syscalls.h>
#include <linux/fcntl.h>
#include <linux/memcontrol.h>

#include <linux/uaccess.h>
#include <asm/ioctls.h>

#include "internal.h"

/*
 * The max size that a non-root user is allowed to grow the pipe. Can
 * be set by root in /proc/sys/fs/pipe-max-size
 */
unsigned int pipe_max_size = 1048576;

/*
 * Minimum pipe size, as required by POSIX
 */
unsigned int pipe_min_size = PAGE_SIZE;

/* Maximum allocatable pages per user. Hard limit is unset by default, soft
 * matches default values.
 */
unsigned long pipe_user_pages_hard;
unsigned long pipe_user_pages_soft = PIPE_DEF_BUFFERS * INR_OPEN_CUR;

/*
 * We use a start+len construction, which provides full use of the 
 * allocated memory.
 * -- Florian Coosmann (FGC)
 * 
 * Reads with count = 0 should always return 0.
 * -- Julian Bradfield 1999-06-07.
 *
 * FIFOs and Pipes now generate SIGIO for both readers and writers.
 * -- Jeremy Elson <jelson@circlemud.org> 2001-08-16
 *
 * pipe_read & write cleanup
 * -- Manfred Spraul <manfred@colorfullife.com> 2002-05-09
 */

static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
{
	if (pipe->files)
		mutex_lock_nested(&pipe->mutex, subclass);
}

void pipe_lock(struct pipe_inode_info *pipe)
{
	/*
	 * pipe_lock() nests non-pipe inode locks (for writing to a file)
	 */
	pipe_lock_nested(pipe, I_MUTEX_PARENT);
}
EXPORT_SYMBOL(pipe_lock);

void pipe_unlock(struct pipe_inode_info *pipe)
{
	if (pipe->files)
		mutex_unlock(&pipe->mutex);
}
EXPORT_SYMBOL(pipe_unlock);

static inline void __pipe_lock(struct pipe_inode_info *pipe)
{
	mutex_lock_nested(&pipe->mutex, I_MUTEX_PARENT);
}

static inline void __pipe_unlock(struct pipe_inode_info *pipe)
{
	mutex_unlock(&pipe->mutex);
}

void pipe_double_lock(struct pipe_inode_info *pipe1,
		      struct pipe_inode_info *pipe2)
{
	BUG_ON(pipe1 == pipe2);

	if (pipe1 < pipe2) {
		pipe_lock_nested(pipe1, I_MUTEX_PARENT);
		pipe_lock_nested(pipe2, I_MUTEX_CHILD);
	} else {
		pipe_lock_nested(pipe2, I_MUTEX_PARENT);
		pipe_lock_nested(pipe1, I_MUTEX_CHILD);
	}
}

/* Drop the inode semaphore and wait for a pipe event, atomically */
void pipe_wait(struct pipe_inode_info *pipe)
{
	DEFINE_WAIT(wait);

	/*
	 * Pipes are system-local resources, so sleeping on them
	 * is considered a noninteractive wait:
	 */
	prepare_to_wait(&pipe->wait, &wait, TASK_INTERRUPTIBLE);
	pipe_unlock(pipe);
	schedule();
	finish_wait(&pipe->wait, &wait);
	pipe_lock(pipe);
}

static void anon_pipe_buf_release(struct pipe_inode_info *pipe,
				  struct pipe_buffer *buf)
{
	struct page *page = buf->page;

	/*
	 * If nobody else uses this page, and we don't already have a
	 * temporary page, let's keep track of it as a one-deep
	 * allocation cache. (Otherwise just release our reference to it)
	 */
	if (page_count(page) == 1 && !pipe->tmp_page)
		pipe->tmp_page = page;
	else
		put_page(page);
}

static