Skip to content

Conversation

@epheien
Copy link
Contributor

@epheien epheien commented Jan 8, 2026

Summary

Fixes a bug where running /help command in Opencode with position='current' configuration triggers an error:

Error executing vim.schedule lua callback: ...opencode.nvim/lua/opencode/api.lua:510: invalid option '%-131' to 'format'

Root Cause

Lua's string.format function has a maximum width limit of 99 characters for format specifiers. When position='current' is configured, the output window opens in the current window with a very large width (e.g., 161 characters). The code calculates max_desc_length = window_width - 30, which can exceed 99 and trigger the "invalid conversion specification" error.

Fix

Cap max_desc_length at 90 characters to stay safely under the 99-character limit:

local max_desc_length = math.min(90, vim.api.nvim_win_get_width(state.windows.output_win) - 30)

Testing

  • Tested with position='current' configuration
  • /help command now works correctly without errors
  • Tested with various window sizes

Lua's string.format has a maximum width limit of 99 characters for format
specifiers. When position='current' is set, the output window can be very
wide, causing the calculated max_desc_length to exceed this limit and
trigger an 'invalid conversion specification' error.

Fix by capping max_desc_length at 90 characters to stay safely under the
99-character limit.
@sudo-tee sudo-tee merged commit fb950fc into sudo-tee:main Jan 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants