Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/core/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,19 @@ impl Indexer {
});

let overlap_start = if line_idx > 0 {
line_idx.saturating_sub(self.chunk_overlap / 40)
// Calculate how many lines we need to include to achieve
// the desired character overlap
let mut overlap_chars = 0;
let mut overlap_lines = 0;
for i in (0..line_idx).rev() {
let line_char_len = lines[i].len() + 1; // +1 for newline
if overlap_chars + line_char_len > self.chunk_overlap {
break;
}
overlap_chars += line_char_len;
overlap_lines += 1;
}
line_idx.saturating_sub(overlap_lines.max(1))
} else {
0
};
Expand Down Expand Up @@ -728,7 +740,19 @@ impl ServerIndexer {
});

let overlap_start = if line_idx > 0 {
line_idx.saturating_sub(self.chunk_overlap / 40)
// Calculate how many lines we need to include to achieve
// the desired character overlap
let mut overlap_chars = 0;
let mut overlap_lines = 0;
for i in (0..line_idx).rev() {
let line_char_len = lines[i].len() + 1; // +1 for newline
if overlap_chars + line_char_len > self.chunk_overlap {
break;
}
overlap_chars += line_char_len;
overlap_lines += 1;
}
line_idx.saturating_sub(overlap_lines.max(1))
} else {
0
};
Expand Down
14 changes: 13 additions & 1 deletion src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,19 @@ impl FileWatcher {
});

let overlap_start = if line_idx > 0 {
line_idx.saturating_sub(self.config.chunk_overlap / 40)
// Calculate how many lines we need to include to achieve
// the desired character overlap
let mut overlap_chars = 0;
let mut overlap_lines = 0;
for i in (0..line_idx).rev() {
let line_char_len = lines[i].len() + 1; // +1 for newline
if overlap_chars + line_char_len > self.config.chunk_overlap {
break;
}
overlap_chars += line_char_len;
overlap_lines += 1;
}
line_idx.saturating_sub(overlap_lines.max(1))
} else {
0
};
Expand Down
Loading