Repository navigation
Slash commands: remove the second /bb registration so /bb always opens the settings (#1360) - #1373
Merged
Merged
Conversation
…s the settings (#1360) BetterBags registered /bb twice. Config:RegisterSettings (config/config.lua) registers it through AceConsole-3.0 as SlashCmdList["ACECONSOLE_BB"], the handler for /bb, /bb help, /bb changelog and /bb next. data/items.lua also set SLASH_BETTERBAGS_DEBUGITEMS1 = "/bb" and SlashCmdList["BETTERBAGS_DEBUGITEMS"], a leftover debug command from #1002 (/bb debugitems printed the harvested backpack items; any other input printed its help line). The client keeps one handler per command: ImportListToHash (Blizzard_ChatFrameBase/Shared/ChatFrameUtil.lua, the same on live, WoW: Forever and the Classic clients) walks SlashCmdList in the table's iteration order and writes hash_SlashCmdList["/BB"] for each entry, the later one replacing the earlier. Which handler survived therefore depended on the other addons a player had installed. Where the debug handler won, /bb, /bb help, /bb changelog and /bb next printed "BetterBags Debug Commands: use '/bb debugitems' ..." instead of running (#1246). Where AceConsole's won, /bb debugitems opened the settings. The debug command is removed rather than moved under the /bb handler: the /bbdb debug window's Dump Backpack Items already records the backpack items, with what the client's APIs answered about each. - data/items.lua: remove the debug slash command and its globals from the luacheck directive. - spec/integration/slash_commands_spec.lua (new, whole addon): /bb, /bbanchor and /bbdb are each claimed by exactly one SlashCmdList entry, Config's; /bb dispatched through a model of ImportListToHash, walking the entries in both orders, opens the settings window. Before the fix the uniqueness test and the first-to-last test failed. spec/config/config_spec.lua stubs RegisterChatCommand, so it could not see the second entry. - .claude/rules/slash-commands.md (new): Config is the only registrar of chat commands, why (the client's import, with source lines per branch), and the history of the duplicate. - config/README.md, docs/handoff.md, docs/render.md: the single registrar, and /bbdb's Dump Backpack Items in place of /bb debugitems. Fixes #1360.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1360. Also addresses the player report in #1246.
Problem
BetterBags registered
/bbtwice:config/config.lua:Config:RegisterSettingsregisters/bbthrough AceConsole-3.0 asSlashCmdList["ACECONSOLE_BB"]. This handler runs/bb,/bb help,/bb changelogand/bb next.data/items.lua:SLASH_BETTERBAGS_DEBUGITEMS1 = "/bb"andSlashCmdList["BETTERBAGS_DEBUGITEMS"], a debug command left over from Phase 2: Data Farming Engine & Graceful Deactivation #1002./bb debugitemsprinted the harvested backpack items, and any other input printed the command's help line.The client keeps one handler per command.
ImportListToHash(Blizzard_ChatFrameBase/Shared/ChatFrameUtil.lua, the same on live, WoW: Forever and the Classic clients) walksSlashCmdListin the table's iteration order and writeshash_SlashCmdList["/BB"]for each entry; a later entry replaces an earlier one. Which handler survived therefore depended on the other addons a player had installed:/bb,/bb help,/bb changelogand/bb nextprinted "BetterBags Debug Commands: use '/bb debugitems' to dump harvested physical items." and did nothing else (/bb no longer opens up settings #1246)./bb debugitemsopened the settings window.Changes
data/items.lua: remove the debug slash command, and remove its globals from the luacheck directive. The command is not moved under the/bbhandler: the/bbdbdebug window's Dump Backpack Items already records the backpack items, with what the client's APIs answered about each.spec/integration/slash_commands_spec.lua(new, whole addon):/bb,/bbanchorand/bbdbare each claimed by exactly oneSlashCmdListentry, the one Config registered. A model ofImportListToHashdispatches/bb, walking the entries first to last and last to first, and/bbopens the settings window in both orders. Before the fix, the uniqueness test and the first-to-last test failed. (spec/config/config_spec.luastubsRegisterChatCommand, so it could not detect a second entry.).claude/rules/slash-commands.md(new): Config is the only file that registers chat commands; the client's import behavior, with source line numbers for each branch; the history of the duplicate.config/README.md,docs/handoff.md,docs/render.md: document the single registrar, and point to/bbdb's Dump Backpack Items in place of/bb debugitems.Testing
~/.local/lua51/bin/busted: 8181 successes, 0 failures (rebased onmainat 5e5b7be).luacheck .: 0 warnings, 0 errors.