Skip to content

Commit

Permalink
fix(code): correct condition for setting CHUNK_START_LINE attribute (#…
Browse files Browse the repository at this point in the history
…3642)

The condition for setting the `CHUNK_START_LINE` attribute was incorrect. It now checks if the text length is not equal to the body length, ensuring the attribute is set only when necessary.
  • Loading branch information
wsxiaoys authored Jan 3, 2025
1 parent edf23ee commit d8e9807
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/tabby-index/src/code/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ impl IndexAttributeBuilder<SourceCode> for CodeBuilder {
code::fields::CHUNK_BODY: body,
});

if text.len() == body.len() {
// When text length is not equal to body length, it means this chunk is not the entire
// content of the file, thus we need to record the start line.
if text.len() != body.len() {
attributes[code::fields::CHUNK_START_LINE] = start_line.into();
}
let embedding = embedding.clone();
Expand Down

0 comments on commit d8e9807

Please sign in to comment.