aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-05 18:04:45 +0800
committerGitHub <noreply@github.com>2024-04-05 18:04:45 +0800
commita500c5f808ccf0b678c935f00e0af4503a5bd724 (patch)
treefaec5c534b49cccfabb239748499d530ea5bc054 /src
parent4add77ddbfbbff0795ee9bcca42b8096a6265049 (diff)
downloadrneovim-a500c5f808ccf0b678c935f00e0af4503a5bd724.tar.gz
rneovim-a500c5f808ccf0b678c935f00e0af4503a5bd724.tar.bz2
rneovim-a500c5f808ccf0b678c935f00e0af4503a5bd724.zip
vim-patch:8.1.0815: dialog for file changed outside of Vim not tested (#28184)
Problem: Dialog for file changed outside of Vim not tested. Solution: Add a test. Move FileChangedShell test. Add 'L' flag to feedkeys(). https://github.com/vim/vim/commit/5e66b42aae7c67a3ef67617d4bd43052ac2b73ce Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c15
-rw-r--r--src/nvim/eval.lua1
-rw-r--r--src/nvim/message.c10
-rw-r--r--src/nvim/os/input.c7
4 files changed, 26 insertions, 7 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 2fb8f3d554..82e9ddff2d 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -277,6 +277,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks)
bool typed = false;
bool execute = false;
bool dangerous = false;
+ bool lowlevel = false;
for (size_t i = 0; i < mode.size; i++) {
switch (mode.data[i]) {
@@ -292,6 +293,8 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks)
execute = true; break;
case '!':
dangerous = true; break;
+ case 'L':
+ lowlevel = true; break;
}
}
@@ -307,10 +310,14 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks)
} else {
keys_esc = keys.data;
}
- ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
- insert ? 0 : typebuf.tb_len, !typed, false);
- if (vgetc_busy) {
- typebuf_was_filled = true;
+ if (lowlevel) {
+ input_enqueue_raw(cstr_as_string(keys_esc));
+ } else {
+ ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
+ insert ? 0 : typebuf.tb_len, !typed, false);
+ if (vgetc_busy) {
+ typebuf_was_filled = true;
+ }
}
if (escape_ks) {
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 6a3eabc467..e40e81f8f2 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -2481,6 +2481,7 @@ M.funcs = {
't' Handle keys as if typed; otherwise they are handled as
if coming from a mapping. This matters for undo,
opening folds, etc.
+ 'L' Lowlevel input. Other flags are not used.
'i' Insert the string instead of appending (see above).
'x' Execute commands until typeahead is empty. This is
similar to using ":normal!". You can call feedkeys()
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 68a8b8e88b..362dc2c05a 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3395,9 +3395,7 @@ int do_dialog(int type, const char *title, const char *message, const char *butt
int retval = 0;
int i;
- if (silent_mode // No dialogs in silent mode ("ex -s")
- || !ui_active() // Without a UI Nvim waits for input forever.
- ) {
+ if (silent_mode) { // No dialogs in silent mode ("ex -s")
return dfltbutton; // return default option
}
@@ -3414,6 +3412,12 @@ int do_dialog(int type, const char *title, const char *message, const char *butt
char *hotkeys = msg_show_console_dialog(message, buttons, dfltbutton);
while (true) {
+ // Without a UI Nvim waits for input forever.
+ if (!ui_active() && !input_available()) {
+ retval = dfltbutton;
+ break;
+ }
+
// Get a typed character directly from the user.
int c = get_keystroke(NULL);
switch (c) {
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 5218e50df6..60b5b48745 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -247,6 +247,13 @@ bool os_isatty(int fd)
return uv_guess_handle(fd) == UV_TTY;
}
+void input_enqueue_raw(String keys)
+{
+ if (keys.size > 0) {
+ rbuffer_write(input_buffer, keys.data, keys.size);
+ }
+}
+
size_t input_enqueue(String keys)
{
const char *ptr = keys.data;