Skip to content

feat(renderer): account for inline virtual text when positioning images#364

Open
charlesg3 wants to merge 1 commit into
3rd:masterfrom
charlesg3:feat/inline-virt-text-offset
Open

feat(renderer): account for inline virtual text when positioning images#364
charlesg3 wants to merge 1 commit into
3rd:masterfrom
charlesg3:feat/inline-virt-text-offset

Conversation

@charlesg3
Copy link
Copy Markdown
Contributor

Summary

When a plugin like render-markdown.nvim injects inline virtual text at the start of an image row (e.g. heading indent), image.nvim currently renders the image flush at column 0, sitting under the virt_text rather than under the displayed ![ of the link.

This change detects inline virt_text extmarks at the image row and offsets absolute_x by their summed display width. The adjustment is guarded by original_x == 0: when the link sits at a non-zero buffer column, treesitter's node:range already reports the indented column, so no further shift is needed.

What's included

  • lua/image/renderer.lua — the fix
  • tests/renderer/inline_virt_text_offset_spec.lua — 5 cases (the shift; no-virt-text passthrough; x>0 passthrough; eol virt_text ignored; multi-chunk width summation)
  • tests/checklists/inline_virt_text_offset.md — manual checklist for visual verification under render-markdown

When a plugin like render-markdown.nvim injects inline virtual text at the
start of an image row (e.g. heading indent), image.nvim renders the image
flush at column 0, sitting under the virt_text instead of under the
displayed position of the link.

Detect inline virt_text extmarks at the image row and offset absolute_x by
their summed display width. The adjustment is guarded by original_x == 0:
when the link sits at a non-zero buffer column, treesitter's node:range
already reports the indented column and no further shift is needed.

Includes:
- tests/renderer/inline_virt_text_offset_spec.lua — 5 cases covering the
  shift, the non-affected paths (no virt_text / x>0 / eol virt_text), and
  multi-chunk virt_text width summation.
- tests/checklists/inline_virt_text_offset.md — manual checklist for
  visual verification with render-markdown.nvim.
@charlesg3 charlesg3 marked this pull request as ready for review May 12, 2026 02:53
charlesg3 added a commit to charlesg3/nvim that referenced this pull request May 12, 2026
PRs #348 (BufEnter on document integration) and #350 (overlap option +
negative render_offset_top support) were merged upstream, so the previous
render-fixes.patch is no longer needed — it's superseded by the upstream
'overlap' option (same math as the local 'existing_lines' field).

- Point bundle/image.nvim submodule at 3rd/image.nvim (master), bump to
  faccd45.
- Drop patches/image.nvim/render-fixes.patch (fully merged upstream).
- Add patches/image.nvim/inline-virt-text-offset.patch for the one
  outstanding hunk (render-markdown indent offset), proposed upstream
  in 3rd/image.nvim#364.
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.

1 participant