[PATCH] Handle case of unmapped K when exiting termdebug

20 views
Skip to first unread message

v...@rkta.de

unread,
Dec 7, 2020, 4:49:37 AM12/7/20
to vim...@googlegroups.com, Rene Kita
From: Rene Kita <g...@rkta.de>

If K is not mapped to anything the dictionary is empty and the if clause
is false. K is then still mapped to :Evaluate. This will result in an
error E492 when using K.
---

Steps to reproduce:
- :unmap K
- :packadd termdebug
- :Termdebug
- quit
- :map K


runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 2 ++
1 file changed, 2 insertions(+)

diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index bf38dc93a..301ac7a5c 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -729,6 +729,8 @@ func s:DeleteCommands()
if exists('s:k_map_saved') && !empty(s:k_map_saved)
call mapset('n', 0, s:k_map_saved)
unlet s:k_map_saved
+ else
+ nunmap K
endif

if has('menu')
--
2.25.1

Bram Moolenaar

unread,
Dec 7, 2020, 12:54:51 PM12/7/20
to vim...@googlegroups.com, v...@rkta.de, Rene Kita

Rene Kita wrote;

> If K is not mapped to anything the dictionary is empty and the if clause
> is false. K is then still mapped to :Evaluate. This will result in an
> error E492 when using K.
> ---
>
> Steps to reproduce:
> - :unmap K
> - :packadd termdebug
> - :Termdebug
> - quit
> - :map K

Thanks for the idea. One more situation to take care of: if
g_termdebug_map_K was set to zero then K wasn't mapped, thus should also
not be unmapped. This should do it:

if exists('s:k_map_saved')
if empty(s:k_map_saved)
nunmap K
else
call mapset('n', 0, s:k_map_saved)
endif
unlet s:k_map_saved
endif


--
BRIDGEKEEPER: What is your favorite colour?
GAWAIN: Blue ... No yelloooooww!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

v...@rkta.de

unread,
Dec 7, 2020, 9:23:46 PM12/7/20
to vim...@vim.org

v...@rkta.de

unread,
Dec 7, 2020, 9:23:46 PM12/7/20
to vim...@vim.org, Rene Kita
From: Rene Kita <g...@rkta.de>

If K is not mapped to anything the dictionary is empty and the if clause
is false. K is then still mapped to :Evaluate. This will result in an
error E492 when using K.
---

Steps to reproduce:
- :unmap K
- :packadd termdebug
- :Termdebug
- quit
- :map K


runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 2 ++
1 file changed, 2 insertions(+)

diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index bf38dc93a..301ac7a5c 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -729,6 +729,8 @@ func s:DeleteCommands()
if exists('s:k_map_saved') && !empty(s:k_map_saved)
call mapset('n', 0, s:k_map_saved)

v...@rkta.de

unread,
Dec 7, 2020, 9:23:46 PM12/7/20
to vim...@vim.org, Rene Kita

Rene Kita

unread,
Dec 8, 2020, 11:13:40 AM12/8/20
to vim...@googlegroups.com
On Mon, Dec 07, 2020 at 06:54:41PM +0100, Bram Moolenaar wrote:
>
> Rene Kita wrote;
>
> > If K is not mapped to anything the dictionary is empty and the if clause
> > is false. K is then still mapped to :Evaluate. This will result in an
> > error E492 when using K.
>
> Thanks for the idea. One more situation to take care of: if
> g_termdebug_map_K was set to zero then K wasn't mapped, thus should also
> not be unmapped. This should do it:
>
> if exists('s:k_map_saved')
> if empty(s:k_map_saved)
> nunmap K
> else
> call mapset('n', 0, s:k_map_saved)
> endif
> unlet s:k_map_saved
> endif

This is obviously the correct solution - consider my patch a bug report.
Reply all
Reply to author
Forward
0 new messages