diff --git a/crates/assistant_tools/src/read_file_tool.rs b/crates/assistant_tools/src/read_file_tool.rs index 13cd6a9eeae7b1c4246dbd928d3f4fa4c2cf2aab..ae24687482efcda0a73fbf4ad96813b270d26f01 100644 --- a/crates/assistant_tools/src/read_file_tool.rs +++ b/crates/assistant_tools/src/read_file_tool.rs @@ -78,29 +78,20 @@ impl Tool for ReadFileTool { .await?; let result = buffer.read_with(cx, |buffer, _cx| { - if buffer - .file() - .map_or(false, |file| file.disk_state().exists()) - { - let text = buffer.text(); - let string = if input.start_line.is_some() || input.end_line.is_some() { - let start = input.start_line.unwrap_or(1); - let lines = text.split('\n').skip(start - 1); - if let Some(end) = input.end_line { - let count = end.saturating_sub(start); - Itertools::intersperse(lines.take(count), "\n").collect() - } else { - Itertools::intersperse(lines, "\n").collect() - } + let text = buffer.text(); + if input.start_line.is_some() || input.end_line.is_some() { + let start = input.start_line.unwrap_or(1); + let lines = text.split('\n').skip(start - 1); + if let Some(end) = input.end_line { + let count = end.saturating_sub(start); + Itertools::intersperse(lines.take(count), "\n").collect() } else { - text - }; - - Ok(string) + Itertools::intersperse(lines, "\n").collect() + } } else { - Err(anyhow!("File does not exist")) + text } - })??; + })?; action_log.update(cx, |log, cx| { log.buffer_read(buffer, cx);