Skip to content

fix: drop blank separator between context-free search matches - #818

Merged
will-lamerton merged 1 commit into
mainfrom
fix/search-results-compact-separator
Aug 7, 2026
Merged

will-lamerton merged 1 commit into
mainfrom
fix/search-results-compact-separator

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

Follow-up to #774, which resolved #766. Picks up the two points raised in that PR's review.

Changes

Drop the blank separator between context-free matches. #774 collapsed each match from two lines to one but kept .join('\n\n'), so a blank line still sat between every match. #766 flagged that separator alongside the layout, so this lands the rest of it. Context blocks keep their blank-line separation, where it genuinely aids legibility.

Decide layout from contextLines rather than sniffing content for a newline. contextLines applies to the whole call, so it is the accurate signal. Sniffing misread any context block that collapsed to a single line, which happens on single-line files and whenever truncation drops every newline from the block. Those rendered with the exact-match header and a doubled line number:

# before, single-line file with contextLines: 3
single.ts:1:1: const onlyLine = 1;

# after
single.ts:1-
1: const onlyLine = 1;

Measured

Real 30-match search (useState across *.tsx):

Test plan

Note

The estimate in #766 of 3-4 tokens per match was mine and it was optimistic. The real figure is closer to 2 characters per match. The win is free and lossless but small, so it is not worth sizing future work off that number.

search_file_contents put a blank line between every match, which #766
flagged as waste alongside the two-line-per-match layout that #774
already removed. Context-free matches now join with a single newline.

Layout is also now decided by the contextLines argument rather than by
sniffing each match's content for a newline. contextLines applies to the
whole call, so it is the accurate signal; sniffing misread any context
block that collapsed to one line, which happens on single-line files and
when truncation drops every newline, rendering them with the exact-match
header and a doubled line number.
@will-lamerton
will-lamerton requested a review from Avtrkrb as a code owner August 7, 2026 12:54
@will-lamerton will-lamerton added clean up performance Speed, memory use or token efficiency labels Aug 7, 2026
@will-lamerton will-lamerton added tokenization clean up performance Speed, memory use or token efficiency labels Aug 7, 2026
@will-lamerton
will-lamerton merged commit f469a55 into main Aug 7, 2026
11 checks passed
@will-lamerton
will-lamerton deleted the fix/search-results-compact-separator branch August 7, 2026 13:06
@will-lamerton will-lamerton added the area:providers LLM providers, models, tokenisation, context limits label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers LLM providers, models, tokenisation, context limits clean up performance Speed, memory use or token efficiency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search_file_contents wastes tokens on multi-line result formatting

1 participant