mirror of
https://github.com/helix-editor/nucleo.git
synced 2025-10-05 23:32:41 +02:00
allow access to injected item while creating filter text
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
# [0.5.0] - 2024-4-2
|
||||
|
||||
## **Breaking Changes**
|
||||
|
||||
* `Injector::push` now passes a reference to the push value to the closure generating the columns
|
||||
|
||||
|
||||
# [0.4.1] - 2024-3-11
|
||||
|
||||
## Bugfixes
|
||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -152,7 +152,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nucleo"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"nucleo-matcher",
|
||||
"parking_lot",
|
||||
|
@@ -2,7 +2,7 @@
|
||||
name = "nucleo"
|
||||
description = "plug and play high performance fuzzy matcher"
|
||||
authors = ["Pascal Kuthe <pascalkuthe@pm.me>"]
|
||||
version = "0.4.1"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
license = "MPL-2.0"
|
||||
repository = "https://github.com/helix-editor/nucleo"
|
||||
|
@@ -137,7 +137,7 @@ impl<T> Vec<T> {
|
||||
}
|
||||
|
||||
/// Appends an element to the back of the vector.
|
||||
pub fn push(&self, value: T, fill_columns: impl FnOnce(&mut [Utf32String])) -> u32 {
|
||||
pub fn push(&self, value: T, fill_columns: impl FnOnce(&T, &mut [Utf32String])) -> u32 {
|
||||
let index = self.inflight.fetch_add(1, Ordering::Release);
|
||||
// the inflight counter is a `u64` to catch overflows of the vector'scapacity
|
||||
let index: u32 = index.try_into().expect("overflowed maximum capacity");
|
||||
@@ -170,11 +170,11 @@ impl<T> Vec<T> {
|
||||
//
|
||||
// 2. any thread trying to `get` this entry will see `active == false`,
|
||||
// and will not try to access it
|
||||
(*entry).slot.get().write(MaybeUninit::new(value));
|
||||
for col in Entry::matcher_cols_raw(entry, self.columns) {
|
||||
col.get().write(MaybeUninit::new(Utf32String::default()))
|
||||
}
|
||||
fill_columns(Entry::matcher_cols_mut(entry, self.columns));
|
||||
fill_columns(&value, Entry::matcher_cols_mut(entry, self.columns));
|
||||
(*entry).slot.get().write(MaybeUninit::new(value));
|
||||
// let other threads know that this entry is active
|
||||
(*entry).active.store(true, Ordering::Release);
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ impl<T> Clone for Injector<T> {
|
||||
impl<T> Injector<T> {
|
||||
/// Appends an element to the list of matched items.
|
||||
/// This function is lock-free and wait-free.
|
||||
pub fn push(&self, value: T, fill_columns: impl FnOnce(&mut [Utf32String])) -> u32 {
|
||||
pub fn push(&self, value: T, fill_columns: impl FnOnce(&T, &mut [Utf32String])) -> u32 {
|
||||
let idx = self.items.push(value, fill_columns);
|
||||
(self.notify)();
|
||||
idx
|
||||
|
Reference in New Issue
Block a user