fix: support file paths with spaces in block headers#1504
Merged
deathbeam merged 1 commit intoCopilotC-Nvim:mainfrom Feb 2, 2026
Merged
fix: support file paths with spaces in block headers#1504deathbeam merged 1 commit intoCopilotC-Nvim:mainfrom
deathbeam merged 1 commit intoCopilotC-Nvim:mainfrom
Conversation
The block header pattern used %S+ (non-whitespace characters) to match file paths, which failed when paths contained spaces. This prevented code blocks from being parsed and made diff acceptance (<C-y>) non-functional for files in directories with spaces. Changes: - Add new pattern with lazy match (.-) to support paths with spaces - Keep original pattern as fallback for compatibility - Pattern now correctly parses headers like: python path=/path/with spaces/file.py start_line=1 end_line=10 Fixes the issue where blocks count remained 0 even when Treesitter correctly identified block_header and block_content nodes. Tested with paths containing spaces and verified that: - Blocks are now correctly parsed and added to message.section.blocks - Diff acceptance mappings (accept_diff, show_diff, etc.) now work - Backward compatibility maintained for paths without spaces
Collaborator
|
@all-contributors add @junqizhang for code |
Contributor
|
I've put up a pull request to add @junqizhang! 🎉 |
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.
Problem
The block header pattern matching in
match_block_header()uses%S+(non-whitespace characters) to capture file paths. This fails when file paths contain spaces, causing:<C-y>,gd,gy, etc.) to be non-functionalExample failing path:
Solution
(.-)to support paths with spaces%S+pattern as fallback for compatibilitystart_line=)Testing
Tested with file paths containing spaces and verified:
message.section.blocksaccept_diff,show_diff,jump_to_diff, etc.)Changes
lua/CopilotChat/ui/chat.lua- Added pattern to support spaces in paths