[vim/vim] fix: [termdebug] correct K/-/+ mappings check (PR #15013)

22 views
Skip to first unread message

Shane-XB-Qian

unread,
Jun 15, 2024, 11:43:57 AM (12 days ago) Jun 15
to vim/vim, Subscribed

// and did same like 'saved_mousemodel' chk


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/15013

Commit Summary

  • 1502035 fix: termdebug correct K/-/+ mappings check

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013@github.com>

errael

unread,
Jun 15, 2024, 1:15:49 PM (12 days ago) Jun 15
to vim/vim, Subscribed

@errael commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>    endif
-  if exists('plus_map_saved')
-    if !empty(plus_map_saved) && !plus_map_saved.buffer
+  if plus_map_saved isnot null_dict
⬇️ Suggested change
-  if plus_map_saved isnot null_dict
+  if plus_map_saved != null

For reference

vim9script
var d1: dict<any> = null_dict
var d2: dict<any> = {}
echo 'is d1 null?' d1 == null
echo 'is d2 null?' d2 == null

outputs

is d1 null? true
is d2 null? false

In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> @@ -1232,32 +1232,38 @@ def DeleteCommands()
   delcommand Var
   delcommand Winbar
 
-  if exists('k_map_saved')
-    if !empty(k_map_saved) && !k_map_saved.buffer
+  if k_map_saved isnot null_dict
⬇️ Suggested change
-  if k_map_saved isnot null_dict
+  if k_map_saved != null

In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>    endif
-  if exists('minus_map_saved')
-    if !empty(minus_map_saved) && !minus_map_saved.buffer
+  if minus_map_saved isnot null_dict
⬇️ Suggested change
-  if minus_map_saved isnot null_dict
+  if minus_map_saved != null


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2120636107@github.com>

Shane-XB-Qian

unread,
Jun 15, 2024, 1:53:19 PM (12 days ago) Jun 15
to vim/vim, Subscribed

@Shane-XB-Qian commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>    endif
-  if exists('plus_map_saved')
-    if !empty(plus_map_saved) && !plus_map_saved.buffer
+  if plus_map_saved isnot null_dict

if you recalled some months ago what we argued in such null/null_obj topic which chris applied your PR,
i am confused now truly null or null_obj which was your taste? 😅
anyway, {} isnot null_dict also is true, specially it is just keeping it same operation as saved_mousemodel did,
so i think ok.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2120681249@github.com>

errael

unread,
Jun 15, 2024, 2:08:52 PM (12 days ago) Jun 15
to vim/vim, Subscribed

@errael commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>    endif
-  if exists('plus_map_saved')
-    if !empty(plus_map_saved) && !plus_map_saved.buffer
+  if plus_map_saved isnot null_dict

strings are the weirdest of them all when it comes to null handling. With strings you must use isnot null_string, as it says at :help null-anomalies

Unlike the other containers, an uninitialized string is equal to null.

I left out some important cases from the example.

echo 'is d1 null_dict?' d1 == null_dict
echo 'is d2 nul_dictl?' d2 == null_dict

Both return true.

!= null is easier to understand than isnot null_dict (at least for me). It also looks like what you'd expect to see in most any other language; to me, that makes it easier to maintain.

As you say, what's currently there works; just not as maintainable (but that's only my opinion)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2120696564@github.com>

ubaldot

unread,
Jun 15, 2024, 3:52:19 PM (12 days ago) Jun 15
to vim/vim, Subscribed

@Shane-XB-Qian Thanks! Could you please add some tests?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/c2170610559@github.com>

Christian Brabandt

unread,
Jun 16, 2024, 2:35:44 AM (12 days ago) Jun 16
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

why the silent!


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap +
       mapset(plus_map_saved)
     elseif empty(plus_map_saved)
-      nunmap +
+      silent! nunmap +

why the silent!


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121119973@github.com>

Shane-XB-Qian

unread,
Jun 16, 2024, 2:49:15 AM (12 days ago) Jun 16
to vim/vim, Subscribed

@Shane-XB-Qian commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

there maybe buf local mapping at source, so e.g gdb had no 'K' mapping actually.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121124895@github.com>

Shane-XB-Qian

unread,
Jun 16, 2024, 2:53:00 AM (12 days ago) Jun 16
to vim/vim, Subscribed

@Shane-XB-Qian commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

there maybe buf local mapping at source window, then e.g gdb window had no 'K' mapping actually.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121129104@github.com>

Christian Brabandt

unread,
Jun 16, 2024, 3:04:12 AM (12 days ago) Jun 16
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> @@ -1232,32 +1232,38 @@ def DeleteCommands()
   delcommand Var
   delcommand Winbar
 
-  if exists('k_map_saved')
-    if !empty(k_map_saved) && !k_map_saved.buffer
+  if k_map_saved isnot null_dict

that is not resolved


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121134175@github.com>

Christian Brabandt

unread,
Jun 16, 2024, 3:04:56 AM (12 days ago) Jun 16
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

alright then, thanks. Can you please make the suggested changes from @errael ?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121134263@github.com>

Shane-XB-Qian

unread,
Jun 16, 2024, 3:35:52 AM (11 days ago) Jun 16
to vim/vim, Subscribed

@Shane-XB-Qian commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

that's a confusion to himself, #15013 (comment) had explained.
// though you accepted his PR vs/over mine in the past about this null/null_obj topic, but just a code style.
// vs this termdebug you had accepted null_obj for saved_mousemodel, a similar flag, so i just kept the same.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121150923@github.com>

Shane-XB-Qian

unread,
Jun 16, 2024, 3:39:01 AM (11 days ago) Jun 16
to vim/vim, Subscribed

@Shane-XB-Qian commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

that's a confusion to himself, #15013 (comment) had explained.
// though you accepted his PR vs/over mine in the past about this null/null_obj topic, but just a code style.
// vs this termdebug you had accepted null_obj for saved_mousemodel, a similar flag, so i just kept the same.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121151404@github.com>

Shane-XB-Qian

unread,
Jun 16, 2024, 3:40:25 AM (11 days ago) Jun 16
to vim/vim, Subscribed

@Shane-XB-Qian commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

> @@ -1232,32 +1232,38 @@ def DeleteCommands()
   delcommand Var
   delcommand Winbar
 
-  if exists('k_map_saved')
-    if !empty(k_map_saved) && !k_map_saved.buffer
+  if k_map_saved isnot null_dict

#15013 (comment)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121151714@github.com>

Christian Brabandt

unread,
Jun 16, 2024, 10:42:02 AM (11 days ago) Jun 16
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/pack/dist/opt/termdebug/plugin/termdebug.vim:

>        nunmap K
       mapset(k_map_saved)
     elseif empty(k_map_saved)
-      nunmap K
+      silent! nunmap K

ah, okay. So you initialize to null_dict and then testing against null_dict should be correct.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/review/2121473633@github.com>

Christian Brabandt

unread,
Jun 16, 2024, 10:46:50 AM (11 days ago) Jun 16
to vim/vim, Subscribed

Closed #15013 via a5af73a.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15013/issue_event/13176169244@github.com>

Reply all
Reply to author
Forward
0 new messages