[audit] Fix vim.ui.img.set() row/col to 1-indexed per documented API - #316
Merged
Conversation
vim.ui.img.Opts.row/col are documented as 1-indexed (see runtime/lua/vim/ui/img.lua and its kitty backend, which builds the cursor-position escape as \027[%d;%dH from opts.row/col). preview_image() passed row = 0, col = 0, which is truthy in Lua so it's forwarded literally as position 0 -- outside the documented contract, relying on terminals clamping 0 to 1 rather than the documented 1-indexed API. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GJzu414NEM2wcAQMtMZYhY
stanfish06
marked this pull request as ready for review
August 10, 2026 14:52
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.
What
vim.ui.img.Opts.row/colare documented as 1-indexed (---@field row? integer starting row (1-indexed)), and the built-in kitty backend builds the cursor-position escape as\027[%d;%dHdirectly fromopts.row or 1/opts.col or 1.Where
lua/config/image.lua:8—preview_image()calledvim.ui.img.set(..., { row = 0, col = 0, ... }).Why it matters
0is truthy in Lua, so it isn't caught by theor 1default and gets forwarded literally, producing the escape sequence for row/col position0— outside the documented 1-indexed contract. Most terminals happen to clamp0to1, which is why this hasn't visibly misbehaved, but it's relying on undefined/non-portable terminal clamping rather than the documented API.vim.ui.imgis still an experimental, actively-changing API (gated behindmin = "0.13"ininit.lua), so keeping call sites strictly conformant matters more than usual here.Related but distinct from #286 (which tracks migrating this whole module to
snacks.imagesincevim.ui.imgis otherwise broken) — this is a narrow correctness fix to the existing call site regardless of that broader migration decision.Recommended action (applied)
Changed
row = 0, col = 0torow = 1, col = 1.Generated by Claude Code