aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/optionstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/optionstr.c')
-rw-r--r--src/nvim/optionstr.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 3372c7b6c6..6c6190cb08 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -67,6 +67,8 @@ static const char e_backupext_and_patchmode_are_equal[]
= N_("E589: 'backupext' and 'patchmode' are equal");
static const char e_showbreak_contains_unprintable_or_wide_character[]
= N_("E595: 'showbreak' contains unprintable or wide character");
+static const char e_internal_error_shortmess_too_long[]
+ = N_("E1336: Internal error: shortmess too long");
static char *(p_ambw_values[]) = { "single", "double", NULL };
static char *(p_bg_values[]) = { "light", "dark", NULL };
@@ -1941,6 +1943,37 @@ int check_ff_value(char *p)
return check_opt_strings(p, p_ff_values, false);
}
+static char shm_buf[SHM_LEN];
+static int set_shm_recursive = 0;
+
+/// Save the acutal shortmess Flags and clear them
+/// temporarily to avoid that file messages
+/// overwrites any output from the following commands.
+///
+/// Caller must make sure to first call save_clear_shm_value() and then
+/// restore_shm_value() exactly the same number of times.
+void save_clear_shm_value(void)
+{
+ if (strlen(p_shm) >= SHM_LEN) {
+ iemsg(e_internal_error_shortmess_too_long);
+ return;
+ }
+
+ if (++set_shm_recursive == 1) {
+ STRCPY(shm_buf, p_shm);
+ set_option_value_give_err("shm", 0L, "", 0);
+ }
+}
+
+/// Restore the shortmess Flags set from the save_clear_shm_value() function.
+void restore_shm_value(void)
+{
+ if (--set_shm_recursive == 0) {
+ set_option_value_give_err("shm", 0L, shm_buf, 0);
+ memset(shm_buf, 0, SHM_LEN);
+ }
+}
+
static const char e_conflicts_with_value_of_listchars[]
= N_("E834: Conflicts with value of 'listchars'");
static const char e_conflicts_with_value_of_fillchars[]