Skip to content

Commit ae565d7

Browse files
committed
Apply cargo fmt
1 parent 3c20ea4 commit ae565d7

6 files changed

Lines changed: 181 additions & 143 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target/
2+
*.lbdb

‎src/backend.rs‎

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ fn graph_node_from_value(val: &Value) -> Option<GraphNode> {
133133
return None;
134134
};
135135
let props = node.get_properties();
136-
let owned: Vec<(String, Value)> = props
137-
.iter()
138-
.map(|(k, v)| (k.clone(), v.clone()))
139-
.collect();
136+
let owned: Vec<(String, Value)> = props.iter().map(|(k, v)| (k.clone(), v.clone())).collect();
140137
let id = format!(
141138
"{}:{}",
142139
node.get_node_id().table_id,
@@ -248,7 +245,11 @@ fn collect_edges_arrow(
248245
node_ids.insert((st, so));
249246
node_ids.insert((dt, doff));
250247
if seen.insert((source.clone(), target.clone(), label.clone())) {
251-
links.push(GraphLink { source, target, label });
248+
links.push(GraphLink {
249+
source,
250+
target,
251+
label,
252+
});
252253
}
253254
}
254255
}
@@ -283,17 +284,15 @@ fn collect_edges_csr(
283284
.context("arrow csr query failed")?;
284285
let csr = result.csr().context("no CSR metadata")?;
285286
let mut meta = conn
286-
.query(&format!("MATCH (a)-[r:{rel}]->(b) RETURN id(a), id(b) LIMIT 1"))
287+
.query(&format!(
288+
"MATCH (a)-[r:{rel}]->(b) RETURN id(a), id(b) LIMIT 1"
289+
))
287290
.context("rel endpoint query failed")?;
288291
let (src_table, dst_table) = match meta.next() {
289-
Some(row) if row.len() >= 2 => {
290-
match (&row[0], &row[1]) {
291-
(Value::InternalID(s), Value::InternalID(d)) => {
292-
(s.table_id, d.table_id)
293-
}
294-
_ => continue,
295-
}
296-
}
292+
Some(row) if row.len() >= 2 => match (&row[0], &row[1]) {
293+
(Value::InternalID(s), Value::InternalID(d)) => (s.table_id, d.table_id),
294+
_ => continue,
295+
},
297296
_ => continue, // empty rel table
298297
};
299298
let indptr = csr.indptr.values();
@@ -354,7 +353,9 @@ pub fn collect_edge_graph(conn: &Connection, limit: usize) -> Result<GraphData>
354353
node_ids = ids;
355354
}
356355
Err(e) => {
357-
eprintln!("bugscope: CSR edge scan unavailable ({e}); falling back to columnar Arrow scan");
356+
eprintln!(
357+
"bugscope: CSR edge scan unavailable ({e}); falling back to columnar Arrow scan"
358+
);
358359
collect_edges_arrow(conn, limit, &mut links, &mut node_ids)?
359360
}
360361
}
@@ -414,10 +415,14 @@ fn enrich_node_properties(
414415
offsets.sort_unstable();
415416
offsets.dedup();
416417
for chunk in offsets.chunks(1000) {
417-
let list = chunk.iter().map(|o| o.to_string()).collect::<Vec<_>>().join(",");
418-
let Ok(mut result) =
419-
conn.query(&format!("MATCH (n:{label}) WHERE offset(id(n)) IN [{list}] RETURN n"))
420-
else {
418+
let list = chunk
419+
.iter()
420+
.map(|o| o.to_string())
421+
.collect::<Vec<_>>()
422+
.join(",");
423+
let Ok(mut result) = conn.query(&format!(
424+
"MATCH (n:{label}) WHERE offset(id(n)) IN [{list}] RETURN n"
425+
)) else {
421426
continue;
422427
};
423428
for row in &mut result {
@@ -468,7 +473,10 @@ pub fn collect_schema_graph(conn: &Connection) -> Result<GraphData> {
468473
properties: HashMap::new(),
469474
})
470475
.collect();
471-
Ok(GraphData { nodes, links: vec![] })
476+
Ok(GraphData {
477+
nodes,
478+
links: vec![],
479+
})
472480
}
473481

474482
/// Substring search over node properties — port of `search_nodes` fallback path.
@@ -531,8 +539,7 @@ pub fn neighborhood(full: &GraphData, focus: &str) -> GraphData {
531539
neighbor_ids.sort_by_key(|id| std::cmp::Reverse(*degrees.get(id).unwrap_or(&0)));
532540
let mut visible: HashSet<&str> = neighbor_ids.into_iter().take(NEIGHBOR_LIMIT).collect();
533541
visible.insert(focus);
534-
let by_id: HashMap<&str, &GraphNode> =
535-
full.nodes.iter().map(|n| (n.id.as_str(), n)).collect();
542+
let by_id: HashMap<&str, &GraphNode> = full.nodes.iter().map(|n| (n.id.as_str(), n)).collect();
536543
let nodes = visible
537544
.iter()
538545
.filter_map(|id| by_id.get(id).cloned().cloned())

‎src/cli.rs‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,24 @@ mod tests {
9999
let opts = parse_cli(&args(&["bugscope", "a.lbdb", "b.lbdb"]))
100100
.unwrap()
101101
.unwrap();
102-
assert_eq!(opts.files, vec![PathBuf::from("a.lbdb"), PathBuf::from("b.lbdb")]);
102+
assert_eq!(
103+
opts.files,
104+
vec![PathBuf::from("a.lbdb"), PathBuf::from("b.lbdb")]
105+
);
103106
assert!(!opts.schema_mode);
104107
}
105108

106109
#[test]
107110
fn options_and_separator() {
108111
let opts = parse_cli(&args(&[
109-
"bugscope", "--dir", "/tmp", "--limit", "500", "--schema", "--", "--weird.lbdb",
112+
"bugscope",
113+
"--dir",
114+
"/tmp",
115+
"--limit",
116+
"500",
117+
"--schema",
118+
"--",
119+
"--weird.lbdb",
110120
]))
111121
.unwrap()
112122
.unwrap();

‎src/model.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ impl GraphModel {
7878
});
7979
}
8080
for l in &data.links {
81-
if let (Some(&s), Some(&t)) = (self.index.get(l.source.as_str()), self.index.get(l.target.as_str())) {
81+
if let (Some(&s), Some(&t)) = (
82+
self.index.get(l.source.as_str()),
83+
self.index.get(l.target.as_str()),
84+
) {
8285
self.links.push(SimLink {
8386
source: s,
8487
target: t,

‎src/theme.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! category at a single saturation/lightness level, with amber (`warning`)
1313
//! kept apart for selection, the primary action, and focus.
1414
15-
use gpui::{Hsla, Window, WindowAppearance, rgb};
15+
use gpui::{rgb, Hsla, Window, WindowAppearance};
1616

1717
#[derive(Clone, Copy)]
1818
pub struct Theme {
@@ -82,15 +82,15 @@ impl Theme {
8282

8383
/// disktree `palette.rs` category hues, shared by both appearances.
8484
const CATEGORY_HUES: [(f32, f32); 9] = [
85-
(0.605, 1.0), // code — blue
86-
(0.065, 1.0), // agent scratch — orange
87-
(0.415, 1.0), // toolchain — teal
88-
(0.535, 1.0), // synced — cyan
89-
(0.955, 1.0), // git — red
90-
(0.745, 1.0), // media — violet
85+
(0.605, 1.0), // code — blue
86+
(0.065, 1.0), // agent scratch — orange
87+
(0.415, 1.0), // toolchain — teal
88+
(0.535, 1.0), // synced — cyan
89+
(0.955, 1.0), // git — red
90+
(0.745, 1.0), // media — violet
9191
(0.125, 0.95), // cache — amber
92-
(0.6, 0.18), // documents — near-neutral
93-
(0.6, 0.08), // other — neutral
92+
(0.6, 0.18), // documents — near-neutral
93+
(0.6, 0.08), // other — neutral
9494
];
9595

9696
fn hsl_to_rgb(h: f32, s: f32, l: f32) -> (f32, f32, f32) {

0 commit comments

Comments
 (0)