Files
DankMaterialShell/core/internal/keybinds
Mario Mohar e1b2279a70 fix(keybinds): show hl.unbind + hl.bind overrides from user Lua modules (#3238)
In Hyprland a second bind on an already bound key does not replace the
first, both stay live, which is why an override is written as hl.unbind
followed by hl.bind. The parser dropped that pair on the floor when it
came from a user's own Lua module:

- parseLuaLines discarded the unbind whenever the same file rebound the
  key, so the DMS default was never removed
- addBind then treated the rebind as a config bind conflicting with a DMS
  bind, counted it in bindsAfterDMS and returned false, so it never
  reached the section

The keybinds modal therefore showed the DMS default for that key and the
user's actual action was nowhere, which is what #3145 reports.

The discard existed to protect dms/binds-user.lua, the file the settings
modal writes, which uses the same unbind+bind pair: recording its unbind
would have deleted its own rebind too, since that file is also a DMS bind
source. The guard was just too coarse, suppressing the unbind entirely
instead of exempting the one bind it belongs to.

Now the unbind is always recorded, and rebindSources remembers which file
unbound and rebound a key so removeUnboundDMSBinds spares that file's own
bind. addBind treats a bind as an override, not a conflict, when the same
file unbound the key earlier — tracked per file in fileUnbinds, saved and
restored around each parsed file so an include cannot leak into its
parent.

A config bind without a preceding unbind is unchanged: both binds really
are live in Hyprland, so it stays a conflict and keeps counting towards
"Some DMS binds may be overridden by config binds".

No other provider has an unbind concept; mangowc, niri and sway parse
formats without one, so this is Hyprland-only.

Tests: hyprland_parser_override_test.go covers the reported case, the
conflict case without an unbind, a bare unbind with no rebind, and the
dms/binds-user.lua round trip. Only the first fails without the fix; the
other three pass either way and guard against over-correcting.
2026-08-31 10:40:41 -04:00
..
2025-11-12 23:12:31 -05:00