From f1e5da6cdd8b02ed028ebf03d2697d0a949e925f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 9 Apr 2019 17:54:29 +0200 Subject: [PATCH] help: don't doubly list toggles that have two keys assigned to them --- src/global.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/global.c b/src/global.c index 858530ab..281c0f77 100644 --- a/src/global.c +++ b/src/global.c @@ -397,7 +397,6 @@ void add_to_sclist(int menus, const char *scstring, const int keycode, sclist = s; else tailsc->next = s; - tailsc = s; s->next = NULL; /* Fill in the data. */ @@ -405,11 +404,14 @@ void add_to_sclist(int menus, const char *scstring, const int keycode, s->func = func; #ifndef NANO_TINY s->toggle = toggle; + /* When not the same toggle as the previous one, increment the ID. */ if (toggle) - s->ordinal = ++counter; + s->ordinal = (tailsc->toggle == toggle) ? counter : ++counter; #endif assign_keyinfo(s, scstring, keycode); + tailsc = s; + #ifdef DEBUG fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus); #endif