feat(autocmd): add Recording autocmds

feat(eval): add reg_recorded()

This function is used the get the last recorded register.

style(Recording): rename handler to match suggestions

fix(RecordingLeave): send autocommand earlier

This makes the autocommand fire just before setting reg_recorded to
reg_recording, this way we clearly show that we are actually just before
actually quitting the recording mode.
This commit is contained in:
Thomas Vigouroux
2021-08-17 15:56:37 +02:00
committed by Axel Dahlberg
parent b1757e1c29
commit 8a4e26c6fe
13 changed files with 131 additions and 21 deletions

View File

@@ -912,13 +912,14 @@ int do_record(int c)
showmode();
regname = c;
retval = OK;
apply_autocmds(EVENT_RECORDINGENTER, NULL, NULL, false, curbuf);
}
} else { // stop recording
/*
* 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.
*/
} else { // stop recording
// 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);
reg_recorded = reg_recording;
reg_recording = 0;
if (ui_has(kUIMessages)) {
showmode();
@@ -932,10 +933,8 @@ int do_record(int c)
// 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.
*/
// We don't want to change the default register here, so save and
// restore the current register name.
old_y_previous = y_previous;
retval = stuff_yank(regname, p);