vim-patch:9.0.2154: The option[] array is not sorted (#26475)

Problem:  The options[] array is not sorted alphabetically.
Solution: Sort it alphabetically.  Add a test.  Avoid unnecessary loop
          iterations in findoption().

closes: vim/vim#13648

Cherry-pick Test_set_one_column() change from patch 8.2.0432.

f48558e10a
This commit is contained in:
zeertzjq
2023-12-09 07:18:21 +08:00
committed by GitHub
parent 9706ee59d0
commit b8e227b621
3 changed files with 299 additions and 294 deletions

View File

@@ -3065,11 +3065,14 @@ int findoption_len(const char *const arg, const size_t len)
opt_idx = quick_tab[CHAR_ORD_LOW(arg[0])];
}
// Match full name
for (; (s = options[opt_idx].fullname) != NULL; opt_idx++) {
for (; (s = options[opt_idx].fullname) != NULL && s[0] == arg[0]; opt_idx++) {
if (strncmp(arg, s, len) == 0 && s[len] == NUL) {
break;
}
}
if (s != NULL && s[0] != arg[0]) {
s = NULL;
}
if (s == NULL && !is_term_opt) {
opt_idx = quick_tab[CHAR_ORD_LOW(arg[0])];
// Match short name