refactor(options): option flags enum #30961

Problem: Currently we use macros with hardcoded flag values for option flags, which is messy and requires a lot of mental math for adding / removing option flags. Using macros for option flags also means that they cannot be used inside debuggers.

Solution: Create a new `OptFlags` enum that stores all the option flags in an organized way that is easier to understand.
This commit is contained in:
Famiu Haque
2024-10-28 19:49:16 +06:00
committed by GitHub
parent 0b7cc014fc
commit 34c44c3556
8 changed files with 144 additions and 150 deletions

View File

@@ -419,9 +419,9 @@ const char *check_stl_option(char *s)
/// often illegal in a file name. Be more permissive if "secure" is off.
bool check_illegal_path_names(char *val, uint32_t flags)
{
return (((flags & P_NFNAME)
return (((flags & kOptFlagNFname)
&& strpbrk(val, (secure ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
|| ((flags & P_NDNAME)
|| ((flags & kOptFlagNDname)
&& strpbrk(val, "*?[|;&<>\r\n") != NULL));
}
@@ -1377,7 +1377,7 @@ const char *did_set_filetype_or_syntax(optset_T *args)
args->os_value_changed = strcmp(args->os_oldval.string.data, *varp) != 0;
// Since we check the value, there is no need to set P_INSECURE,
// Since we check the value, there is no need to set kOptFlagInsecure,
// even when the value comes from a modeline.
args->os_value_checked = true;
@@ -1658,7 +1658,7 @@ const char *did_set_keymap(optset_T *args)
secure = secure_save;
// Since we check the value, there is no need to set P_INSECURE,
// Since we check the value, there is no need to set kOptFlagInsecure,
// even when the value comes from a modeline.
args->os_value_checked = true;