fix: handle '%' in filenames when expanding templates - #901
Open
ethanstoner wants to merge 1 commit into
Open
ethanstoner wants to merge 1 commit into
ethanstoner wants to merge 1 commit into
Conversation
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.
Bug
Formatting or running
:ConformInfoon a buffer whose path contains a%(e.g.my%20notes.md) fails with:Root cause
string.gsubtreats%in a string replacement as special (%0-%9are capture references,%%is a literal percent). The file path was passed straight in as the replacement string in two places:build_context:template:gsub("$RANDOM", ...):gsub("$FILENAME", basename)when building the temp file name (stdin = false)build_cmd:$FILENAME,$DIRNAMEand$EXTENSIONreplacements whenargsis a string$RELATIVE_FILEPATHalready used a function replacement, so it was unaffected. List-styleargsdo not usegsuband were also fine.Change
Use function replacements for those
gsubcalls. The return value of a replacement function is inserted literally, so%in paths no longer gets interpreted. No othergsubcalls in the plugin take path-derived replacement strings.Tests
Added to
tests/runner_spec.lua:build_contexttemp file name with a%20filename and directory (failed withinvalid capture indexbefore the fix)build_cmdstring args$FILENAME $DIRNAME $EXTENSIONwith a%20path (failed withinvalid capture indexbefore the fix)build_cmdlist args with a%20path (already passed; regression guard)./run_tests.shon nvim 0.12 (macOS): all new tests pass. Three tests fail identically on unmodifiedmasterin my environment, so they are unrelated to this change:runner e2e sets the correct output,fuzzer formats correctly,injected formatter inline.ts.stylua --check lua testsandluacheck lua testspass.Fixes #725
Generated with Claude Code on behalf of @ethanstoner.