Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 5171c46

Browse files
authored
Fix autocomplete repo match (#1218)
* make repo_name ; make autocomplete and folder queries case insensitive; remove repo.display_name() * use stringified repo_ref in prompt
1 parent cf3ca70 commit 5171c46

File tree

8 files changed

+12
-15
lines changed

8 files changed

+12
-15
lines changed

server/bleep/src/agent/prompts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ pub fn system<'a>(paths: impl IntoIterator<Item = &'a RepoPath>) -> String {
100100
if iter.peek().is_some() {
101101
s.push_str("\n## PATHS ##\nindex, repo, path\n");
102102
for (i, path) in iter.enumerate() {
103-
let repo = path.repo.display_name();
103+
let repo = &path.repo;
104+
let repo = &format!("{repo}");
104105
let path = &path.path;
105106
s.push_str(&format!("{}, {}, {}\n", i, repo, path));
106107
}

server/bleep/src/agent/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Agent {
6565
.to_string(),
6666
token_info_request: TokenInfoRequest {
6767
relative_path: chunk.repo_path.path.clone(),
68-
repo_ref: chunk.repo_path.repo.display_name(),
68+
repo_ref: chunk.repo_path.repo.indexed_name(),
6969
branch: None,
7070
start: range.start.byte,
7171
end: range.end.byte,

server/bleep/src/indexes/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl File {
8080

8181
let repo_disk_path = builder.add_text_field("repo_disk_path", STRING);
8282
let repo_ref = builder.add_text_field("repo_ref", STRING | STORED);
83-
let repo_name = builder.add_text_field("repo_name", trigram.clone());
83+
let repo_name = builder.add_text_field("repo_name", STRING | STORED);
8484
let relative_path = builder.add_text_field("relative_path", trigram.clone());
8585

8686
let content = builder.add_text_field("content", trigram.clone());

server/bleep/src/query/compiler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub fn case_permutations(s: &str) -> impl Iterator<Item = CompactString> {
255255

256256
// Make sure not to overflow. The end condition is a mask with the highest bit set, and we use
257257
// `u32` masks.
258-
debug_assert!(chars.len() <= 31);
258+
debug_assert!(chars.len() <= 5);
259259

260260
let num_chars = chars.len();
261261

server/bleep/src/repo.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,14 @@ impl RepoRef {
9797

9898
pub fn indexed_name(&self) -> String {
9999
// Local repos indexed as: dirname
100-
// Github repos indexed as: github.com/org/repo
100+
// Github repos indexed as: org/repo
101101
match self.backend {
102102
Backend::Local => Path::new(&self.name)
103103
.file_name()
104104
.expect("last component is `..`")
105105
.to_string_lossy()
106106
.into(),
107-
Backend::Github => format!("{}", self),
108-
}
109-
}
110-
111-
pub fn display_name(&self) -> String {
112-
match self.backend {
113-
// org_name/repo_name
114107
Backend::Github => self.name.to_owned(),
115-
// repo_name
116-
Backend::Local => self.indexed_name(),
117108
}
118109
}
119110

server/bleep/src/webserver/autocomplete.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ pub(super) async fn handle(
5252
let queries = parser::parse(&api_params.q)
5353
.map_err(Error::user)?
5454
.into_iter()
55+
.map(|q| parser::Query {
56+
case_sensitive: Some(true),
57+
..q
58+
})
5559
.map(|mut q| {
5660
let keywords = &["lang:", "path:", "repo:"];
5761

server/bleep/src/webserver/file.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub(super) async fn folder(
100100
repo: Some(parser::Literal::from(&params.repo_ref.indexed_name())),
101101
path: Some(parser::Literal::from(params.path.to_string_lossy())),
102102
branch: params.branch.map(|b| parser::Literal::from(&b)),
103+
case_sensitive: Some(true),
103104
..Default::default()
104105
};
105106

server/bleep/src/webserver/repos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl From<(&RepoRef, &Repository)> for Repo {
128128

129129
Repo {
130130
provider: key.backend(),
131-
name: key.display_name(),
131+
name: key.indexed_name(),
132132
repo_ref: key.clone(),
133133
sync_status: repo.pub_sync_status.clone(),
134134
local_duplicates: vec![],

0 commit comments

Comments
 (0)