Skip to content

Commit 5c5e6c2

Browse files
authored
fix: support file paths with spaces in block headers (#1504)
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
1 parent 6933b82 commit 5c5e6c2

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

lua/CopilotChat/ui/chat.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ local function match_block_header(header)
3939
end
4040

4141
local patterns = {
42+
'^(%w+)%s+path=(.-)%s+start_line=(%d+)%s+end_line=(%d+)$',
4243
'^(%w+)%s+path=(%S+)%s+start_line=(%d+)%s+end_line=(%d+)$',
4344
'^(%w+)$',
4445
}

0 commit comments

Comments
 (0)