The problem is that I can not find a way to obtain the current mode before key <c-\><c-n> takes effect in terminal mode.
I want to restore the pos of cursor in terminal when reloading it in a popup:
Cause actions such as recording modes, closing popup, restoring positions are done by functions, which means I need return from terminal mode to normal mode first by <c-\><c-n> and then call functions. If I perform record action in function, then I will alway got n through mode().
So if it possible to add a autocommands like InsertLeave and InsertLeavepre or there is some other way I do not know to handle such case.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
So if it possible to add autocommands like InsertLeave and InsertLeavepre
Relevant todo item:
or there is some other way I do not know to handle such case.
Cause actions such as recording modes, closing popup and restoring positions are done in functions, which means I need return from terminal mode to normal mode first by <c-> and then call functions. If I perform record action in function, then I will alway get n through mode().
When calling your function, try to use the pseudo-key <cmd> (require patch 8.2.1978):
tnoremap <key> <c-\><c-n>:call MyFunc()<cr>
^---------^
✘
tnoremap <key> <cmd>call MyFunc()<cr>
^---^
✔
Alternatively, you could try to emulate the TermEnter and TermLeave events by firing them manually via custom mappings. That's what I do in this gist.
When calling your function, try to use the pseudo-key
<cmd>(require patch 8.2.1978):tnoremap <key> <c-\><c-n>:call MyFunc()<cr> ^---------^ ✘ tnoremap <key> <cmd>call MyFunc()<cr> ^---^ ✔
It helps a lot! Thanks a lot.
Glad it helps. Note that there is already a bug report currently open which asks for a TermLeave event: #2487
Fixed in patch 8.2.3555.
Use ModeChanged nt:t instead of TerminalEnter and ModeChanged t:nt instead of TerminalLeave.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
![]()