We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f794d37 commit 3e0dbd8Copy full SHA for 3e0dbd8
1 file changed
crates/code_assistant/src/acp/explorer.rs
@@ -247,7 +247,10 @@ impl CodeExplorer for AcpCodeExplorer {
247
}
248
let total_lines = lines.len();
249
let start = start_line.unwrap_or(1).saturating_sub(1);
250
- let end = end_line.unwrap_or(total_lines).saturating_sub(1);
+ // Cap end to total_lines - 1 to prevent out-of-bounds access
251
+ let end = end_line
252
+ .map(|e| e.saturating_sub(1).min(total_lines - 1))
253
+ .unwrap_or(total_lines - 1);
254
if start >= total_lines || start > end {
255
return Err(anyhow!(
256
"Invalid line range: start={}, end={}, total_lines={}",
0 commit comments