commit 5a3bd329d60803385954f3c63c0d5cc68725d82a
parent 8b4bf2bb8ddec5929f66740b345c0cfd9c4a4235
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 18 Aug 2022 15:49:22 +0200
prompt: prevent execution of inadmissible functions in view mode
This fixes https://savannah.gnu.org/bugs/?62912.
Bug existed since commit 958ec294 from earlier today,
but was enabled by commit 433dd921 from three days ago.
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/prompt.c b/src/prompt.c
@@ -367,9 +367,12 @@ int do_statusbar_input(bool *finished)
}
#endif
else {
- /* Handle some other shortcut, and indicate that we're done. */
- function();
- *finished = TRUE;
+ /* Handle any other permissible shortcut, and stamp as done. */
+ if (!ISSET(VIEW_MODE) || !changes_something(function)) {
+ function();
+ *finished = TRUE;
+ } else
+ beep();
}
}
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -427,6 +427,7 @@ void terminal_init(void);
void confirm_margin(void);
#endif
void unbound_key(int code);
+bool changes_something(const void *f);
void inject(char *burst, size_t count);
/* Most functions in prompt.c. */