Skip to content

Commit 1412bae

Browse files
committed
Formatting fixes
1 parent 32cca94 commit 1412bae

4 files changed

Lines changed: 107 additions & 66 deletions

File tree

crates/loom-core/src/schema.rs

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ impl LdapConnection {
195195

196196
let mut last_err = None;
197197
for (i, schema_dn) in dns_to_try.iter().enumerate() {
198-
debug!("load_schema: attempt {}/{} — trying DN {:?}", i + 1, dns_to_try.len(), schema_dn);
198+
debug!(
199+
"load_schema: attempt {}/{} — trying DN {:?}",
200+
i + 1,
201+
dns_to_try.len(),
202+
schema_dn
203+
);
199204
match self.try_load_schema_from(schema_dn).await {
200205
Ok(cache) if !cache.attribute_types.is_empty() => {
201206
debug!(
@@ -220,13 +225,19 @@ impl LdapConnection {
220225
}
221226
}
222227

223-
debug!("load_schema: all {} DNs exhausted, returning error", dns_to_try.len());
228+
debug!(
229+
"load_schema: all {} DNs exhausted, returning error",
230+
dns_to_try.len()
231+
);
224232
Err(last_err.unwrap_or_else(|| CoreError::SchemaError("No schema found".into())))
225233
}
226234

227235
/// Try to load schema from a specific DN.
228236
async fn try_load_schema_from(&mut self, schema_dn: &str) -> Result<SchemaCache, CoreError> {
229-
debug!("try_load_schema_from: searching base={:?} scope=Base filter=(objectClass=*)", schema_dn);
237+
debug!(
238+
"try_load_schema_from: searching base={:?} scope=Base filter=(objectClass=*)",
239+
schema_dn
240+
);
230241
let result = self
231242
.ldap
232243
.search(
@@ -237,18 +248,26 @@ impl LdapConnection {
237248
)
238249
.await
239250
.map_err(|e| {
240-
debug!("try_load_schema_from: LDAP search error for {:?}: {}", schema_dn, e);
251+
debug!(
252+
"try_load_schema_from: LDAP search error for {:?}: {}",
253+
schema_dn, e
254+
);
241255
CoreError::Ldap(e)
242256
})?;
243257

244-
let (entries, _res) = result
245-
.success()
246-
.map_err(|e| {
247-
debug!("try_load_schema_from: search result error for {:?}: {}", schema_dn, e);
248-
CoreError::SchemaError(format!("Schema search failed: {}", e))
249-
})?;
258+
let (entries, _res) = result.success().map_err(|e| {
259+
debug!(
260+
"try_load_schema_from: search result error for {:?}: {}",
261+
schema_dn, e
262+
);
263+
CoreError::SchemaError(format!("Schema search failed: {}", e))
264+
})?;
250265

251-
debug!("try_load_schema_from: got {} entries from {:?}", entries.len(), schema_dn);
266+
debug!(
267+
"try_load_schema_from: got {} entries from {:?}",
268+
entries.len(),
269+
schema_dn
270+
);
252271

253272
let mut cache = SchemaCache::new();
254273

@@ -264,7 +283,10 @@ impl LdapConnection {
264283

265284
// Parse attributeTypes
266285
if let Some(attr_types) = find_values_ci(&attrs, "attributetypes") {
267-
debug!("try_load_schema_from: found {} attributeTypes definitions", attr_types.len());
286+
debug!(
287+
"try_load_schema_from: found {} attributeTypes definitions",
288+
attr_types.len()
289+
);
268290
let mut parsed_count = 0u32;
269291
let mut failed_count = 0u32;
270292
for def in attr_types {
@@ -291,12 +313,18 @@ impl LdapConnection {
291313
parsed_count, failed_count
292314
);
293315
} else {
294-
debug!("try_load_schema_from: no 'attributeTypes' attribute found in entry from {:?}", schema_dn);
316+
debug!(
317+
"try_load_schema_from: no 'attributeTypes' attribute found in entry from {:?}",
318+
schema_dn
319+
);
295320
}
296321

297322
// Parse objectClasses
298323
if let Some(obj_classes) = find_values_ci(&attrs, "objectclasses") {
299-
debug!("try_load_schema_from: found {} objectClasses definitions", obj_classes.len());
324+
debug!(
325+
"try_load_schema_from: found {} objectClasses definitions",
326+
obj_classes.len()
327+
);
300328
let mut parsed_count = 0u32;
301329
let mut failed_count = 0u32;
302330
for def in obj_classes {
@@ -318,7 +346,10 @@ impl LdapConnection {
318346
parsed_count, failed_count
319347
);
320348
} else {
321-
debug!("try_load_schema_from: no 'objectClasses' attribute found in entry from {:?}", schema_dn);
349+
debug!(
350+
"try_load_schema_from: no 'objectClasses' attribute found in entry from {:?}",
351+
schema_dn
352+
);
322353
}
323354

324355
debug!(

crates/loom-tui/src/app.rs

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,7 @@ impl App {
363363

364364
let read_only = profile.read_only;
365365
let ro_suffix = if read_only { " (read-only)" } else { "" };
366-
let conn_msg = format!(
367-
"Connected to {} (base: {}){}",
368-
host, base_dn, ro_suffix
369-
);
366+
let conn_msg = format!("Connected to {} (base: {}){}", host, base_dn, ro_suffix);
370367
self.status_bar.set_message(conn_msg.clone());
371368
self.log_panel.push_info(conn_msg);
372369
self.status_bar.set_connected(&host, &server_type_str);
@@ -975,9 +972,7 @@ impl App {
975972
let connection = connection.clone();
976973
tokio::spawn(async move {
977974
let mut conn = connection.lock().await;
978-
let result = match conn
979-
.search_limited(&base_dn, &filter, &["*"], 50)
980-
.await
975+
let result = match conn.search_limited(&base_dn, &filter, &["*"], 50).await
981976
{
982977
Ok(entries) => Ok(entries),
983978
Err(e) if LdapConnection::is_connection_error(&e) => {
@@ -1166,7 +1161,8 @@ impl App {
11661161
&& matches!(
11671162
self.keymap.resolve_global_only(&key),
11681163
Action::SearchFocusInput
1169-
) {
1164+
)
1165+
{
11701166
self.dismiss_all_popups();
11711167
if self.active_layout != ActiveLayout::Browser {
11721168
let _ = self
@@ -1288,9 +1284,7 @@ impl App {
12881284
} else {
12891285
// Try panel-specific handler first, fall back to global keymap
12901286
let panel_action = match self.focus.current() {
1291-
FocusTarget::TreePanel => {
1292-
self.tree_panel.handle_key_event(key)
1293-
}
1287+
FocusTarget::TreePanel => self.tree_panel.handle_key_event(key),
12941288
FocusTarget::DetailPanel => {
12951289
self.detail_panel.handle_key_event(key)
12961290
}
@@ -1663,10 +1657,7 @@ impl App {
16631657
if let Some(profile) = self.last_adhoc_profile.take() {
16641658
match AppConfig::append_connection(&profile) {
16651659
Ok(()) => {
1666-
let save_msg = format!(
1667-
"Saved connection '{}' to config",
1668-
profile.name
1669-
);
1660+
let save_msg = format!("Saved connection '{}' to config", profile.name);
16701661
self.status_bar.set_message(save_msg.clone());
16711662
self.log_panel.push_info(save_msg);
16721663
self.config.connections.push(profile);
@@ -1890,8 +1881,7 @@ impl App {
18901881
// Search
18911882
Action::SearchExecute(filter) => {
18921883
if let Err(e) = loom_core::filter::validate_filter(&filter) {
1893-
self.status_bar
1894-
.set_error(format!("Invalid filter: {}", e));
1884+
self.status_bar.set_error(format!("Invalid filter: {}", e));
18951885
// Re-activate input so user can fix the filter
18961886
self.command_panel.resume_input();
18971887
self.command_panel.input_buffer = filter;
@@ -2019,10 +2009,8 @@ impl App {
20192009
}
20202010
}
20212011
Action::AttributeSaved(dn) => {
2022-
let saved_msg = format!(
2023-
"Saved changes to {}",
2024-
loom_core::dn::rdn_display_name(&dn)
2025-
);
2012+
let saved_msg =
2013+
format!("Saved changes to {}", loom_core::dn::rdn_display_name(&dn));
20262014
self.status_bar.set_message(saved_msg.clone());
20272015
self.log_panel.push_info(saved_msg);
20282016
// Refresh the entry
@@ -2120,10 +2108,8 @@ impl App {
21202108
}
21212109
}
21222110
Action::EntryCreated(dn) => {
2123-
let created_msg = format!(
2124-
"Created entry: {}",
2125-
loom_core::dn::rdn_display_name(&dn)
2126-
);
2111+
let created_msg =
2112+
format!("Created entry: {}", loom_core::dn::rdn_display_name(&dn));
21272113
self.status_bar.set_message(created_msg.clone());
21282114
self.log_panel.push_info(created_msg);
21292115
// Refresh parent's children in the tree
@@ -2140,10 +2126,8 @@ impl App {
21402126
}
21412127
}
21422128
Action::EntryDeleted(dn) => {
2143-
let deleted_msg = format!(
2144-
"Deleted entry: {}",
2145-
loom_core::dn::rdn_display_name(&dn)
2146-
);
2129+
let deleted_msg =
2130+
format!("Deleted entry: {}", loom_core::dn::rdn_display_name(&dn));
21472131
self.status_bar.set_message(deleted_msg.clone());
21482132
self.log_panel.push_info(deleted_msg);
21492133
// Clear detail panel if showing the deleted entry
@@ -2217,11 +2201,18 @@ impl App {
22172201
// Update command panel autocomplete if this is the active tab
22182202
if self.active_tab_id == Some(conn_id) {
22192203
if schema_empty {
2220-
debug!("SchemaLoaded: calling set_fallback_attributes for conn_id={}", conn_id);
2204+
debug!(
2205+
"SchemaLoaded: calling set_fallback_attributes for conn_id={}",
2206+
conn_id
2207+
);
22212208
self.command_panel.set_fallback_attributes();
22222209
} else {
22232210
let names = schema.all_attribute_names();
2224-
debug!("SchemaLoaded: setting {} attribute names from schema for conn_id={}", names.len(), conn_id);
2211+
debug!(
2212+
"SchemaLoaded: setting {} attribute names from schema for conn_id={}",
2213+
names.len(),
2214+
conn_id
2215+
);
22252216
self.command_panel.set_attribute_names(names);
22262217
}
22272218
self.command_panel.set_schema(Some(*schema.clone()));

crates/loom-tui/src/components/command_panel.rs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use crossterm::event::{KeyCode, KeyEvent};
22
use ratatui::layout::{Constraint, Layout, Rect};
33
use ratatui::text::{Line, Span};
4-
use ratatui::widgets::{Block, BorderType, Borders, Cell, Clear, List, ListItem, Paragraph, Row, Table};
4+
use ratatui::widgets::{
5+
Block, BorderType, Borders, Cell, Clear, List, ListItem, Paragraph, Row, Table,
6+
};
57
use ratatui::Frame;
68
use tracing::debug;
79

@@ -273,7 +275,10 @@ impl CommandPanel {
273275
match context {
274276
Some(FilterContext::Empty) => {
275277
// Show filter templates
276-
debug!("update_completions: showing {} filter templates", FILTER_TEMPLATES.len());
278+
debug!(
279+
"update_completions: showing {} filter templates",
280+
FILTER_TEMPLATES.len()
281+
);
277282
self.completion_kind = CompletionKind::Templates;
278283
self.value_items = FILTER_TEMPLATES.iter().map(|s| s.to_string()).collect();
279284
self.completions = self
@@ -306,7 +311,9 @@ impl CommandPanel {
306311
self.attribute_names.len(),
307312
);
308313
if !self.completions.is_empty() {
309-
let top_matches: Vec<&str> = self.completions.iter()
314+
let top_matches: Vec<&str> = self
315+
.completions
316+
.iter()
310317
.take(5)
311318
.map(|m| self.attribute_names[m.index].as_str())
312319
.collect();
@@ -360,7 +367,9 @@ impl CommandPanel {
360367
}
361368
debug!(
362369
"update_completions: Value attr={:?}, partial={:?}, {} value completions",
363-
attr, partial, self.completions.len()
370+
attr,
371+
partial,
372+
self.completions.len()
364373
);
365374
self.completions.truncate(50);
366375
self.completion_visible = !self.completions.is_empty();
@@ -378,7 +387,11 @@ impl CommandPanel {
378387

379388
fn accept_completion(&mut self) {
380389
if !self.completion_visible || self.completions.is_empty() {
381-
debug!("accept_completion: nothing to accept (visible={}, count={})", self.completion_visible, self.completions.len());
390+
debug!(
391+
"accept_completion: nothing to accept (visible={}, count={})",
392+
self.completion_visible,
393+
self.completions.len()
394+
);
382395
return;
383396
}
384397

@@ -407,7 +420,10 @@ impl CommandPanel {
407420
self.input_buffer.push('=');
408421
self.cursor_pos = self.input_buffer.len();
409422
self.input_buffer.push_str(&suffix);
410-
debug!("accept_completion: buffer is now {:?}, cursor_pos={}", self.input_buffer, self.cursor_pos);
423+
debug!(
424+
"accept_completion: buffer is now {:?}, cursor_pos={}",
425+
self.input_buffer, self.cursor_pos
426+
);
411427
}
412428
}
413429
CompletionKind::Values => {
@@ -431,7 +447,10 @@ impl CommandPanel {
431447
self.input_buffer.push(')');
432448
self.cursor_pos = self.input_buffer.len();
433449
self.input_buffer.push_str(&suffix);
434-
debug!("accept_completion: buffer is now {:?}, cursor_pos={}", self.input_buffer, self.cursor_pos);
450+
debug!(
451+
"accept_completion: buffer is now {:?}, cursor_pos={}",
452+
self.input_buffer, self.cursor_pos
453+
);
435454
}
436455
}
437456
CompletionKind::Templates => {
@@ -482,7 +501,8 @@ impl CommandPanel {
482501
} else {
483502
debug!(
484503
"tick: filter {:?} invalid: {:?}",
485-
self.input_buffer, validation.err()
504+
self.input_buffer,
505+
validation.err()
486506
);
487507
Action::None
488508
}
@@ -738,8 +758,7 @@ impl CommandPanel {
738758
return;
739759
}
740760

741-
let target_row =
742-
(cursor_row as i32 + delta).clamp(0, (lines.len() - 1) as i32) as usize;
761+
let target_row = (cursor_row as i32 + delta).clamp(0, (lines.len() - 1) as i32) as usize;
743762
if target_row == cursor_row {
744763
return;
745764
}
@@ -805,7 +824,7 @@ impl CommandPanel {
805824
current_line = format!("{}{}{}", indent_str.repeat(indent), ch, chars[i + 1]);
806825
let row = lines.len();
807826
let col_base = indent * indent_str.len();
808-
cursor_map.push((row, col_base)); // '('
827+
cursor_map.push((row, col_base)); // '('
809828
cursor_map.push((row, col_base + 1)); // '&'/'|'/'!'
810829
lines.push(current_line);
811830
current_line = String::new();
@@ -1061,8 +1080,7 @@ impl CommandPanel {
10611080
Constraint::Percentage(25),
10621081
];
10631082

1064-
let table = Table::new(rows, widths)
1065-
.header(header.style(self.theme.header));
1083+
let table = Table::new(rows, widths).header(header.style(self.theme.header));
10661084

10671085
frame.render_widget(table, inner);
10681086
}
@@ -1076,7 +1094,12 @@ impl CommandPanel {
10761094
let (formatted_lines, cursor_row, cursor_col, _) = if self.input_active {
10771095
self.format_input_for_display()
10781096
} else {
1079-
(vec![self.input_buffer.clone()], 0, self.input_buffer.len(), Vec::new())
1097+
(
1098+
vec![self.input_buffer.clone()],
1099+
0,
1100+
self.input_buffer.len(),
1101+
Vec::new(),
1102+
)
10801103
};
10811104

10821105
if self.input_active {
@@ -1277,10 +1300,7 @@ impl Component for CommandPanel {
12771300
Span::styled(at.to_string(), self.theme.command_prompt),
12781301
];
12791302
if !after.is_empty() {
1280-
spans.push(Span::styled(
1281-
after.to_string(),
1282-
self.theme.normal,
1283-
));
1303+
spans.push(Span::styled(after.to_string(), self.theme.normal));
12841304
}
12851305
Line::from(spans)
12861306
} else {

crates/loom-tui/src/components/layout_bar.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ impl LayoutBar {
6363
x += 3;
6464

6565
for tab in tabs {
66-
let is_active =
67-
self.active == ActiveLayout::Browser && active_tab == Some(tab.id);
66+
let is_active = self.active == ActiveLayout::Browser && active_tab == Some(tab.id);
6867
let style = if is_active {
6968
self.theme.tab_active
7069
} else {

0 commit comments

Comments
 (0)