Skip to content

fix: fall back to /tmp for buffers without a backing file#60

Merged
barrettruth merged 2 commits intomainfrom
fix/tmpfile-fallback
Mar 13, 2026
Merged

fix: fall back to /tmp for buffers without a backing file#60
barrettruth merged 2 commits intomainfrom
fix/tmpfile-fallback

Conversation

@barrettruth
Copy link
Owner

Problem

Markdown and gfm presets fail when the buffer has no file on disk (e.g. unnamed buffer with ft=markdown, or a named buffer whose path doesn't exist yet) because build_context passes a nonexistent path to pandoc and the public API guards reject empty buffer names.

Solution

build_context detects missing files and redirects ctx.file to /tmp/{bufnr}-{name}. compiler.compile writes buffer contents to that temp path via vim.fn.writefile instead of :silent! update. The early-return guards on empty buffer names are removed so unnamed buffers flow through to provider resolution normally.

Problem: markdown and gfm presets fail when the buffer has no file on
disk (e.g. unnamed buffer with `ft=markdown`, or a named buffer whose
path doesn't exist yet) because `build_context` passes a nonexistent
path to pandoc and `compile` guards reject empty buffer names.

Solution: `build_context` now detects missing files and redirects
`ctx.file` to `/tmp/{bufnr}-{name}`. `compile` writes buffer contents
to that temp path via `vim.fn.writefile` instead of `:silent! update`.
Problem: the unnamed buffer guard tests expected a "no file name"
warning that no longer exists after the tmpfile fallback change.

Solution: update assertions to expect the downstream messages that
unnamed buffers now reach ("no provider configured", "no output file").
@barrettruth barrettruth merged commit f185ae7 into main Mar 13, 2026
7 checks passed
@barrettruth barrettruth deleted the fix/tmpfile-fallback branch March 13, 2026 12:22
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