Skip to content

Commit df989ab

Browse files
committed
chore: Fix CI - typos, rustfmt, stylua, lls
1 parent d5fafe5 commit df989ab

7 files changed

Lines changed: 104 additions & 29 deletions

File tree

crates/fff-core/src/dbs/db_healthcheck.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub trait DbHealthChecker {
2323
fn get_health(&self) -> Result<DbHealth> {
2424
let env = self.get_env();
2525

26-
let size = env.real_disk_size().map_err(crate::error::Error::GenericDbError)?;
26+
let size = env
27+
.real_disk_size()
28+
.map_err(crate::error::Error::GenericDbError)?;
2729
let path = env.path().to_string_lossy().to_string();
2830
let entry_counts = self.count_entries()?;
2931

crates/fff-core/src/dbs/lmdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
use heed::{Database, Env, EnvOpenOptions};
12
use std::fs;
23
use std::path::Path;
34
use std::sync::Arc;
45
use std::sync::RwLock;
56
use std::sync::atomic::{AtomicU8, Ordering};
67
use std::thread;
78
use std::time::Duration;
8-
use heed::{Database, Env, EnvOpenOptions};
99

1010
use crate::error::{Error, Result};
1111

@@ -67,7 +67,7 @@ impl DbHealth {
6767

6868
/// Spawns a background thread that is ensuring that the environment that was previously
6969
/// open is safe, accessible and doesn't have a corrupted lock.md file. If it does this thread will
70-
/// hang indefinetely but we will have the information that the database is in failure mode
70+
/// hang indefinitely but we will have the information that the database is in failure mode
7171
pub(crate) fn spawn_lmdb_gc<T: LmdbStore>(shared: Arc<RwLock<Option<T>>>) {
7272
let thread_shared = shared.clone();
7373
let spawn_result = thread::Builder::new()

crates/fff-core/src/dbs/query_tracker.rs

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,35 @@ impl DbHealthChecker for QueryTracker {
4747
}
4848

4949
fn count_entries(&self) -> Result<Vec<(&'static str, u64)>, Error> {
50-
let rtxn = self.env.read_txn().map_err(|source| Error::DbStartReadTxn { db: Self::LABEL, source })?;
50+
let rtxn = self
51+
.env
52+
.read_txn()
53+
.map_err(|source| Error::DbStartReadTxn {
54+
db: Self::LABEL,
55+
source,
56+
})?;
5157

52-
let count_queries = self.query_file_db.len(&rtxn).map_err(|source| Error::DbRead { db: Self::LABEL, source })?;
53-
let count_histories = self.query_history_db.len(&rtxn).map_err(|source| Error::DbRead { db: Self::LABEL, source })?;
54-
let count_grep_histories = self
55-
.grep_query_history_db
58+
let count_queries = self
59+
.query_file_db
60+
.len(&rtxn)
61+
.map_err(|source| Error::DbRead {
62+
db: Self::LABEL,
63+
source,
64+
})?;
65+
let count_histories = self
66+
.query_history_db
5667
.len(&rtxn)
57-
.map_err(|source| Error::DbRead { db: Self::LABEL, source })?;
68+
.map_err(|source| Error::DbRead {
69+
db: Self::LABEL,
70+
source,
71+
})?;
72+
let count_grep_histories =
73+
self.grep_query_history_db
74+
.len(&rtxn)
75+
.map_err(|source| Error::DbRead {
76+
db: Self::LABEL,
77+
source,
78+
})?;
5879

5980
Ok(vec![
6081
("query_file_entries", count_queries),
@@ -150,7 +171,10 @@ impl QueryTracker {
150171
) -> Result<(), Error> {
151172
let mut history = db
152173
.get(wtxn, project_key)
153-
.map_err(|source| Error::DbRead { db: Self::LABEL, source })?
174+
.map_err(|source| Error::DbRead {
175+
db: Self::LABEL,
176+
source,
177+
})?
154178
.unwrap_or_default();
155179

156180
history.push_back(HistoryEntry {
@@ -162,7 +186,10 @@ impl QueryTracker {
162186
}
163187

164188
db.put(wtxn, project_key, &history)
165-
.map_err(|source| Error::DbWrite { db: Self::LABEL, source })?;
189+
.map_err(|source| Error::DbWrite {
190+
db: Self::LABEL,
191+
source,
192+
})?;
166193
Ok(())
167194
}
168195

@@ -174,11 +201,17 @@ impl QueryTracker {
174201
project_key: &[u8; 32],
175202
offset: usize,
176203
) -> Result<Option<String>, Error> {
177-
let rtxn = env.read_txn().map_err(|source| Error::DbStartReadTxn { db: Self::LABEL, source })?;
204+
let rtxn = env.read_txn().map_err(|source| Error::DbStartReadTxn {
205+
db: Self::LABEL,
206+
source,
207+
})?;
178208

179209
let mut history = db
180210
.get(&rtxn, project_key)
181-
.map_err(|source| Error::DbRead { db: Self::LABEL, source })?
211+
.map_err(|source| Error::DbRead {
212+
db: Self::LABEL,
213+
source,
214+
})?
182215
.unwrap_or_default();
183216

184217
// history is FIFO, last element is most recent
@@ -201,12 +234,21 @@ impl QueryTracker {
201234
let file_path_buf = file_path.to_path_buf();
202235

203236
let query_key = Self::create_query_key(project_path, query)?;
204-
let mut wtxn = self.env.write_txn().map_err(|source| Error::DbStartWriteTxn { db: Self::LABEL, source })?;
237+
let mut wtxn = self
238+
.env
239+
.write_txn()
240+
.map_err(|source| Error::DbStartWriteTxn {
241+
db: Self::LABEL,
242+
source,
243+
})?;
205244

206245
let mut entry = self
207246
.query_file_db
208247
.get(&wtxn, &query_key)
209-
.map_err(|source| Error::DbRead { db: Self::LABEL, source })?
248+
.map_err(|source| Error::DbRead {
249+
db: Self::LABEL,
250+
source,
251+
})?
210252
.unwrap_or_else(|| QueryMatchEntry {
211253
file_path: file_path_buf.clone(),
212254
open_count: 0,
@@ -257,7 +299,9 @@ impl QueryTracker {
257299
if let Err(e) =
258300
Self::append_to_history(&self.query_history_db, &mut wtxn, &project_key, query, now)
259301
{
260-
if let Error::DbWrite { source: ref inner, .. } = e
302+
if let Error::DbWrite {
303+
source: ref inner, ..
304+
} = e
261305
&& is_map_full(inner)
262306
{
263307
self.health.mark_unhealthy("MDB_MAP_FULL on history append");
@@ -290,12 +334,21 @@ impl QueryTracker {
290334
min_combo_count: u32,
291335
) -> Result<Option<QueryMatchEntry>, Error> {
292336
let query_key = Self::create_query_key(project_path, query)?;
293-
let rtxn = self.env.read_txn().map_err(|source| Error::DbStartReadTxn { db: Self::LABEL, source })?;
337+
let rtxn = self
338+
.env
339+
.read_txn()
340+
.map_err(|source| Error::DbStartReadTxn {
341+
db: Self::LABEL,
342+
source,
343+
})?;
294344

295345
let last_match = self
296346
.query_file_db
297347
.get(&rtxn, &query_key)
298-
.map_err(|source| Error::DbRead { db: Self::LABEL, source })?;
348+
.map_err(|source| Error::DbRead {
349+
db: Self::LABEL,
350+
source,
351+
})?;
299352

300353
Ok(last_match.filter(|entry| entry.open_count >= min_combo_count))
301354
}
@@ -309,13 +362,21 @@ impl QueryTracker {
309362
) -> Result<i32, Error> {
310363
let query_key = Self::create_query_key(project_path, query)?;
311364
tracing::debug!(?query_key, "HASH");
312-
let rtxn = self.env.read_txn().map_err(|source| Error::DbStartReadTxn { db: Self::LABEL, source })?;
365+
let rtxn = self
366+
.env
367+
.read_txn()
368+
.map_err(|source| Error::DbStartReadTxn {
369+
db: Self::LABEL,
370+
source,
371+
})?;
313372

314373
match self
315374
.query_file_db
316375
.get(&rtxn, &query_key)
317-
.map_err(|source| Error::DbRead { db: Self::LABEL, source })?
318-
{
376+
.map_err(|source| Error::DbRead {
377+
db: Self::LABEL,
378+
source,
379+
})? {
319380
Some(entry) => {
320381
// Check if the file path matches and return boost
321382
if entry.file_path == file_path && entry.open_count >= 2 {
@@ -344,7 +405,13 @@ impl QueryTracker {
344405
pub fn track_grep_query(&mut self, query: &str, project_path: &Path) -> Result<(), Error> {
345406
let now = self.get_now();
346407
let project_key = Self::create_project_key(project_path)?;
347-
let mut wtxn = self.env.write_txn().map_err(|source| Error::DbStartWriteTxn { db: Self::LABEL, source })?;
408+
let mut wtxn = self
409+
.env
410+
.write_txn()
411+
.map_err(|source| Error::DbStartWriteTxn {
412+
db: Self::LABEL,
413+
source,
414+
})?;
348415

349416
if let Err(e) = Self::append_to_history(
350417
&self.grep_query_history_db,
@@ -353,7 +420,9 @@ impl QueryTracker {
353420
query,
354421
now,
355422
) {
356-
if let Error::DbWrite { source: ref inner, .. } = e
423+
if let Error::DbWrite {
424+
source: ref inner, ..
425+
} = e
357426
&& is_map_full(inner)
358427
{
359428
self.health

crates/fff-core/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum Error {
2626
path: std::path::PathBuf,
2727
source: std::io::Error,
2828
},
29-
#[error("Something is wrong with the local db insance: {0}")]
29+
#[error("Something is wrong with the local db instance: {0}")]
3030
GenericDbError(#[from] heed::Error),
3131
#[error("Failed to open {db} database env: {source}")]
3232
EnvOpen {

lua/fff/health.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ function M.run(opts)
250250
end
251251

252252
report_db_health(rust_health.frecency, health.rust.frecency, health.messages, 'Frecency database', {
253-
populate = function(section, db_info)
254-
section.entries = db_info.absolute_frecency_entries
255-
end,
253+
populate = function(section, db_info) section.entries = db_info.absolute_frecency_entries end,
256254
format_healthy_msg = function(db_info)
257255
return string.format(
258256
'Frecency database operational (%d entries, %s, path: %s)',

lua/fff/picker_ui.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,13 @@ local function compute_layout(config)
262262
total_width = width,
263263
-- Top/bottom preview with prompt-top has a 2-row chrome over-subtraction in
264264
-- calculate_layout_dimensions (BORDER_SIZE is subtracted twice). Compensate at fullscreen.
265-
total_height = (is_fullscreen and prompt_position == 'top'
266-
and (preview_position == 'top' or preview_position == 'bottom')) and height + 2 or height,
265+
total_height = (
266+
is_fullscreen
267+
and prompt_position == 'top'
268+
and (preview_position == 'top' or preview_position == 'bottom')
269+
)
270+
and height + 2
271+
or height,
267272
start_col = col,
268273
start_row = row,
269274
preview_position = preview_position,

tests/fresh_db_open_test.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ if type(results) ~= 'table' then die('fuzzy_search_files did not return a table'
5050
ok(string.format('fuzzy_search_files returned %d results', #(results.items or results)))
5151

5252
-- Give the GC thread up to ~2s to flip Pending -> Healthy
53+
---@type any
5354
local health = nil
5455
local deadline = vim.loop.now() + 2000
5556
while vim.loop.now() < deadline do

0 commit comments

Comments
 (0)