Mercurial > vim
comparison src/option.c @ 31950:b0717fcca5eb v9.0.1307
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Commit: https://github.com/vim/vim/commit/32ff96ef018eb1a5bea0953648b4892a6ee71658
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Feb 13 16:10:04 2023 +0000
patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Problem: Setting 'formatoptions' with :let doesn't check for errors.
Solution: Pass "errbuf" to set_string_option(). (Yegappan Lakshmanan,
closes #11974, closes #11972)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 13 Feb 2023 17:15:04 +0100 |
parents | 6072c1d9fe2a |
children | 360efef7e5df |
comparison
equal
deleted
inserted
replaced
31949:490cc052f7d9 | 31950:b0717fcca5eb |
---|---|
5133 int opt_flags) // OPT_LOCAL or 0 (both) | 5133 int opt_flags) // OPT_LOCAL or 0 (both) |
5134 { | 5134 { |
5135 int opt_idx; | 5135 int opt_idx; |
5136 char_u *varp; | 5136 char_u *varp; |
5137 long_u flags; | 5137 long_u flags; |
5138 static char errbuf[80]; | |
5138 | 5139 |
5139 opt_idx = findoption(name); | 5140 opt_idx = findoption(name); |
5140 if (opt_idx < 0) | 5141 if (opt_idx < 0) |
5141 { | 5142 { |
5142 int key; | 5143 int key; |
5175 emsg(_(e_not_allowed_in_sandbox)); | 5176 emsg(_(e_not_allowed_in_sandbox)); |
5176 return NULL; | 5177 return NULL; |
5177 } | 5178 } |
5178 #endif | 5179 #endif |
5179 if (flags & P_STRING) | 5180 if (flags & P_STRING) |
5180 return set_string_option(opt_idx, string, opt_flags); | 5181 return set_string_option(opt_idx, string, opt_flags, errbuf); |
5181 | 5182 |
5182 varp = get_varp_scope(&(options[opt_idx]), opt_flags); | 5183 varp = get_varp_scope(&(options[opt_idx]), opt_flags); |
5183 if (varp != NULL) // hidden option is not changed | 5184 if (varp != NULL) // hidden option is not changed |
5184 { | 5185 { |
5185 if (number == 0 && string != NULL) | 5186 if (number == 0 && string != NULL) |
5200 return NULL; // do nothing as we hit an error | 5201 return NULL; // do nothing as we hit an error |
5201 | 5202 |
5202 } | 5203 } |
5203 } | 5204 } |
5204 if (flags & P_NUM) | 5205 if (flags & P_NUM) |
5206 { | |
5205 return set_num_option(opt_idx, varp, number, | 5207 return set_num_option(opt_idx, varp, number, |
5206 NULL, 0, opt_flags); | 5208 errbuf, sizeof(errbuf), opt_flags); |
5209 } | |
5207 else | 5210 else |
5208 return set_bool_option(opt_idx, varp, (int)number, opt_flags); | 5211 return set_bool_option(opt_idx, varp, (int)number, opt_flags); |
5209 } | 5212 } |
5210 | 5213 |
5211 } | 5214 } |