Skip to content

Commit 253b2d9

Browse files
committed
refactor: add actions to renderer, remove formatter state
Also hook up context menu autocmds so they show up now. Haven't tested if they acutally work
1 parent 9f50645 commit 253b2d9

File tree

7 files changed

+304
-226
lines changed

7 files changed

+304
-226
lines changed

lua/opencode/api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ function M.undo()
577577
-- ui.render_output(true)
578578
state.api_client
579579
:revert_message(state.active_session.id, {
580-
messageID = last_user_message.id,
580+
messageID = last_user_message.info.id,
581581
})
582582
:and_then(function(response)
583583
state.active_session.revert = response.revert

lua/opencode/state.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local config = require('opencode.config')
2525
---@field current_model_info table|nil
2626
---@field messages OpencodeMessage[]|nil
2727
---@field current_message OpencodeMessage|nil
28-
---@field last_user_message MessageInfo|nil
28+
---@field last_user_message OpencodeMessage|nil
2929
---@field current_permission OpencodePermission|nil
3030
---@field cost number
3131
---@field tokens_count number

lua/opencode/ui/contextual_actions.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ local function clear_keymaps(buf)
1616
current_keymaps = {}
1717
end
1818

19-
function M.setup_contextual_actions()
19+
function M.setup_contextual_actions(windows)
2020
local ns_id = vim.api.nvim_create_namespace('opencode_contextual_actions')
2121
local augroup = vim.api.nvim_create_augroup('OpenCodeContextualActions', { clear = true })
2222

2323
vim.api.nvim_create_autocmd('CursorHold', {
2424
group = augroup,
25-
buffer = state.windows.output_buf,
25+
buffer = windows.output_buf,
2626
callback = function()
2727
vim.schedule(function()
2828
local line_num = vim.api.nvim_win_get_cursor(0)[1]
29-
local actions = require('opencode.ui.formatter').output:get_actions_for_line(line_num)
29+
local actions = require('opencode.ui.renderer').get_actions_for_line(line_num)
3030
last_line_num = line_num
3131

3232
vim.api.nvim_buf_clear_namespace(state.windows.output_buf, ns_id, 0, -1)
@@ -42,7 +42,7 @@ function M.setup_contextual_actions()
4242

4343
vim.api.nvim_create_autocmd('CursorMoved', {
4444
group = augroup,
45-
buffer = state.windows.output_buf,
45+
buffer = windows.output_buf,
4646
callback = function()
4747
vim.schedule(function()
4848
if not output_window.mounted() then
@@ -59,7 +59,7 @@ function M.setup_contextual_actions()
5959

6060
vim.api.nvim_create_autocmd({ 'BufLeave', 'BufDelete', 'BufHidden' }, {
6161
group = augroup,
62-
buffer = state.windows.output_buf,
62+
buffer = windows.output_buf,
6363
callback = function()
6464
vim.api.nvim_buf_clear_namespace(state.windows.output_buf, ns_id, 0, -1)
6565
clear_keymaps(state.windows.output_buf)

0 commit comments

Comments
 (0)