add tests for rust context parsing, and update rust embedding query

Co-authored-by: maxbrunsfeld <max@zed.dev>
This commit is contained in:
KCaverly 2023-07-13 16:58:42 -04:00
parent 0a0e40fb24
commit 623cb9833c
3 changed files with 178 additions and 46 deletions

View file

@ -81,7 +81,11 @@ impl CodeContextRetriever {
if let Some((item, byte_range)) = item.zip(byte_range) {
if !name.is_empty() {
let item = format!("{}\n{}", context_spans.join("\n"), item);
let item = if context_spans.is_empty() {
item.to_string()
} else {
format!("{}\n{}", context_spans.join("\n"), item)
};
let document_text = CODE_CONTEXT_TEMPLATE
.replace("<path>", relative_path.to_str().unwrap())