Skip to content

Commit 8ab1627

Browse files
committed
Merge remote-tracking branch 'origin/rcc/tools' into dev/rust
# Conflicts: # rust/crates/runtime/src/file_ops.rs
2 parents b8dadbf + 46581fe commit 8ab1627

2 files changed

Lines changed: 718 additions & 16 deletions

File tree

‎rust/crates/runtime/src/file_ops.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,20 +296,20 @@ pub fn grep_search(input: &GrepSearchInput) -> io::Result<GrepSearchOutput> {
296296
continue;
297297
}
298298

299-
let Ok(file_content) = fs::read_to_string(&file_path) else {
299+
let Ok(file_contents) = fs::read_to_string(&file_path) else {
300300
continue;
301301
};
302302

303303
if output_mode == "count" {
304-
let count = regex.find_iter(&file_content).count();
304+
let count = regex.find_iter(&file_contents).count();
305305
if count > 0 {
306306
filenames.push(file_path.to_string_lossy().into_owned());
307307
total_matches += count;
308308
}
309309
continue;
310310
}
311311

312-
let lines: Vec<&str> = file_content.lines().collect();
312+
let lines: Vec<&str> = file_contents.lines().collect();
313313
let mut matched_lines = Vec::new();
314314
for (index, line) in lines.iter().enumerate() {
315315
if regex.is_match(line) {
@@ -327,21 +327,21 @@ pub fn grep_search(input: &GrepSearchInput) -> io::Result<GrepSearchOutput> {
327327
for index in matched_lines {
328328
let start = index.saturating_sub(input.before.unwrap_or(context));
329329
let end = (index + input.after.unwrap_or(context) + 1).min(lines.len());
330-
for (current, line_content) in lines.iter().enumerate().take(end).skip(start) {
330+
for (current, line) in lines.iter().enumerate().take(end).skip(start) {
331331
let prefix = if input.line_numbers.unwrap_or(true) {
332332
format!("{}:{}:", file_path.to_string_lossy(), current + 1)
333333
} else {
334334
format!("{}:", file_path.to_string_lossy())
335335
};
336-
content_lines.push(format!("{prefix}{line_content}"));
336+
content_lines.push(format!("{prefix}{line}"));
337337
}
338338
}
339339
}
340340
}
341341

342342
let (filenames, applied_limit, applied_offset) =
343343
apply_limit(filenames, input.head_limit, input.offset);
344-
let rendered_content = if output_mode == "content" {
344+
let content_output = if output_mode == "content" {
345345
let (lines, limit, offset) = apply_limit(content_lines, input.head_limit, input.offset);
346346
return Ok(GrepSearchOutput {
347347
mode: Some(output_mode),
@@ -361,7 +361,7 @@ pub fn grep_search(input: &GrepSearchInput) -> io::Result<GrepSearchOutput> {
361361
mode: Some(output_mode.clone()),
362362
num_files: filenames.len(),
363363
filenames,
364-
content: rendered_content,
364+
content: content_output,
365365
num_lines: None,
366366
num_matches: (output_mode == "count").then_some(total_matches),
367367
applied_limit,

0 commit comments

Comments
 (0)