Remove needless into

This commit is contained in:
Agus Zubiaga 2025-08-07 19:55:43 -03:00
parent 4d94b9c2c2
commit 5bfe086bf4

View file

@ -95,7 +95,7 @@ impl AgentTool for ReadFileTool {
cx: &mut App, cx: &mut App,
) -> Task<Result<String>> { ) -> Task<Result<String>> {
let Some(project_path) = self.project.read(cx).find_project_path(&input.path, cx) else { let Some(project_path) = self.project.read(cx).find_project_path(&input.path, cx) else {
return Task::ready(Err(anyhow!("Path {} not found in project", &input.path))).into(); return Task::ready(Err(anyhow!("Path {} not found in project", &input.path)));
}; };
// Error out if this path is either excluded or private in global settings // Error out if this path is either excluded or private in global settings
@ -104,16 +104,14 @@ impl AgentTool for ReadFileTool {
return Task::ready(Err(anyhow!( return Task::ready(Err(anyhow!(
"Cannot read file because its path matches the global `file_scan_exclusions` setting: {}", "Cannot read file because its path matches the global `file_scan_exclusions` setting: {}",
&input.path &input.path
))) )));
.into();
} }
if global_settings.is_path_private(&project_path.path) { if global_settings.is_path_private(&project_path.path) {
return Task::ready(Err(anyhow!( return Task::ready(Err(anyhow!(
"Cannot read file because its path matches the global `private_files` setting: {}", "Cannot read file because its path matches the global `private_files` setting: {}",
&input.path &input.path
))) )));
.into();
} }
// Error out if this path is either excluded or private in worktree settings // Error out if this path is either excluded or private in worktree settings
@ -122,16 +120,14 @@ impl AgentTool for ReadFileTool {
return Task::ready(Err(anyhow!( return Task::ready(Err(anyhow!(
"Cannot read file because its path matches the worktree `file_scan_exclusions` setting: {}", "Cannot read file because its path matches the worktree `file_scan_exclusions` setting: {}",
&input.path &input.path
))) )));
.into();
} }
if worktree_settings.is_path_private(&project_path.path) { if worktree_settings.is_path_private(&project_path.path) {
return Task::ready(Err(anyhow!( return Task::ready(Err(anyhow!(
"Cannot read file because its path matches the worktree `private_files` setting: {}", "Cannot read file because its path matches the worktree `private_files` setting: {}",
&input.path &input.path
))) )));
.into();
} }
let file_path = input.path.clone(); let file_path = input.path.clone();
@ -226,13 +222,9 @@ impl AgentTool for ReadFileTool {
let lines = text.split('\n').skip(start_row as usize); let lines = text.split('\n').skip(start_row as usize);
if let Some(end) = input.end_line { if let Some(end) = input.end_line {
let count = end.saturating_sub(start).saturating_add(1); // Ensure at least 1 line let count = end.saturating_sub(start).saturating_add(1); // Ensure at least 1 line
itertools::intersperse(lines.take(count as usize), "\n") itertools::intersperse(lines.take(count as usize), "\n").collect::<String>()
.collect::<String>()
.into()
} else { } else {
itertools::intersperse(lines, "\n") itertools::intersperse(lines, "\n").collect::<String>()
.collect::<String>()
.into()
} }
})?; })?;
@ -265,7 +257,7 @@ impl AgentTool for ReadFileTool {
log.buffer_read(buffer, cx); log.buffer_read(buffer, cx);
})?; })?;
Ok(result.into()) Ok(result)
} else { } else {
// File is too big, so return the outline // File is too big, so return the outline
// and a suggestion to read again with line numbers. // and a suggestion to read again with line numbers.