You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: ripgrep search result handling and formatting (#1831)
Problem:
- Previous implementation incorrectly grouped context lines with matches
- Context lines were split into beforeContext/afterContext arrays, making it difficult to maintain proper line order
- Output format was inconsistent with read_file output
- Non-contiguous search results were sometimes broken or incorrectly grouped
- Example of incorrect output:
# bench/bundle-test/rollup.config.mjs
16 | file: 'dist/index-wasm.min.mjs',
17 | format: 'es',
24 | output: {
----
25 | file: 'dist/index-lite.min.mjs',
26 | format: 'es',
----
# packages/rehype/package.json
----
10 | it('run', async () => {
27 | "files": [
28 | "dist"
----
Solution:
- Replace separate context arrays with a single 'lines' array containing both matches and context
- Add isMatch flag to distinguish between match and context lines
- Improve contiguity detection by checking if line numbers are sequential
- Standardize output format to match read_file output
- Properly handle non-contiguous search results by creating new result groups
- Example of correct output:
# bench/bundle-test/rollup.config.mjs
16 | file: 'dist/index-wasm.min.mjs',
17 | format: 'es',
----
24 | output: {
25 | file: 'dist/index-lite.min.mjs',
26 | format: 'es',
----
This change ensures search results are properly grouped and displayed with the correct context.
Signed-off-by: Eric Wheeler <[email protected]>
Co-authored-by: Eric Wheeler <[email protected]>
0 commit comments