Skip to content

Commit a82b08c

Browse files
committed
fix: prefix replacement not working properly
1 parent 9d949e7 commit a82b08c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lua/opencode/config.lua

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,20 @@ local function get_function_names(keymap_config)
173173
end
174174

175175
function update_keymap_prefix(prefix, default_prefix)
176-
for _, mappings in pairs(M.values.keymap) do
177-
for key, func in pairs(mappings) do
178-
if prefix ~= '' and key:sub(1, #default_prefix) == default_prefix then
179-
mappings[prefix .. key:sub(#default_prefix + 1)] = func
180-
mappings[key] = nil
176+
if prefix == default_prefix or not prefix then
177+
return
178+
end
179+
180+
for category, mappings in pairs(M.values.keymap) do
181+
local new_mappings = {}
182+
for key, opts in pairs(mappings) do
183+
if vim.startswith(key, default_prefix) then
184+
new_mappings[prefix .. key:sub(#default_prefix + 1)] = opts
185+
else
186+
new_mappings[key] = opts
181187
end
182188
end
189+
M.values.keymap[category] = new_mappings
183190
end
184191
end
185192

0 commit comments

Comments
 (0)