aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorAxel Dahlberg <git@valleymnt.com>2022-01-05 02:55:29 +0100
committerGitHub <noreply@github.com>2022-01-04 18:55:29 -0700
commitf65b0d4236eef69b02390a51cf335b0836f35801 (patch)
tree00175e033fb56d070dc20c5b3d15f9c3fca2f7d3 /src/nvim/ops.c
parenta45b578dbe6ba02ba9a052a7b058f4243d38a07b (diff)
downloadrneovim-f65b0d4236eef69b02390a51cf335b0836f35801.tar.gz
rneovim-f65b0d4236eef69b02390a51cf335b0836f35801.tar.bz2
rneovim-f65b0d4236eef69b02390a51cf335b0836f35801.zip
feat(autocmd): populate v:event in RecordingLeave (#16828)
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 6c2db1e9ac..013a78bdac 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -915,10 +915,29 @@ int do_record(int c)
apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf);
}
} else { // stop recording
+ save_v_event_T save_v_event;
+ // Set the v:event dictionary with information about the recording.
+ dict_T *dict = get_v_event(&save_v_event);
+
+ // The recorded text contents.
+ p = get_recorded();
+ if (p != NULL) {
+ // Remove escaping for CSI and K_SPECIAL in multi-byte chars.
+ vim_unescape_csi(p);
+ (void)tv_dict_add_str(dict, S_LEN("regcontents"), (const char *)p);
+ }
+
+ // Name of requested register, or empty string for unnamed operation.
+ char buf[NUMBUFLEN+2];
+ buf[0] = (char)regname;
+ buf[1] = NUL;
+ (void)tv_dict_add_str(dict, S_LEN("regname"), buf);
+
// Get the recorded key hits. K_SPECIAL and CSI will be escaped, this
// needs to be removed again to put it in a register. exec_reg then
// adds the escaping back later.
apply_autocmds(EVENT_RECORDINGLEAVE, NULL, NULL, false, curbuf);
+ restore_v_event(dict, &save_v_event);
reg_recorded = reg_recording;
reg_recording = 0;
if (ui_has(kUIMessages)) {
@@ -926,13 +945,9 @@ int do_record(int c)
} else {
msg("");
}
- p = get_recorded();
if (p == NULL) {
retval = FAIL;
} else {
- // Remove escaping for CSI and K_SPECIAL in multi-byte chars.
- vim_unescape_csi(p);
-
// We don't want to change the default register here, so save and
// restore the current register name.
old_y_previous = y_previous;