Skip to content

Commit 946af3a

Browse files
committed
fix(slash_commands): allow slash_commands to be entered in input window
This should fix #71
1 parent abc1e2a commit 946af3a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lua/opencode/ui/input_window.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ function M.handle_submit()
6262
return
6363
end
6464

65-
if input_content:match('^/') then
65+
local key = config.get_key_for_function('input_window', 'slash_commands') or '/'
66+
if input_content:match('^' .. key) then
6667
M._execute_slash_command(input_content)
6768
return
6869
end
@@ -71,16 +72,21 @@ function M.handle_submit()
7172
end
7273

7374
M._execute_slash_command = function(command)
74-
local slash_commands = require('opencode.config_file').get_user_commands()
75+
local slash_commands = require('opencode.api').get_slash_commands()
76+
local key = config.get_key_for_function('input_window', 'slash_commands') or '/'
77+
7578
local cmd = command:sub(2):match('^%s*(.-)%s*$')
7679
if cmd == '' then
7780
return
7881
end
7982
local parts = vim.split(cmd, ' ')
80-
local command_cfg = slash_commands[parts[1]]
83+
84+
local command_cfg = vim.tbl_filter(function(c)
85+
return c.slash_cmd == key .. parts[1]
86+
end, slash_commands)[1]
8187

8288
if command_cfg then
83-
require('opencode.api').run_user_command(parts[1], vim.list_slice(parts, 2))
89+
command_cfg.fn(vim.list_slice(parts, 2))
8490
else
8591
vim.notify('Unknown command: ' .. cmd, vim.log.levels.WARN)
8692
end

0 commit comments

Comments
 (0)