mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 14:21:32 +03:00
fix: use BTreeSet
for selected files to maintain order (#799)
This commit is contained in:
parent
b10f2de16d
commit
78b98a98c3
@ -1,15 +1,15 @@
|
|||||||
use std::{collections::{HashMap, HashSet}, ops::Deref};
|
use std::{collections::{BTreeSet, HashMap}, ops::Deref};
|
||||||
|
|
||||||
use yazi_shared::fs::{FilesOp, Url};
|
use yazi_shared::fs::{FilesOp, Url};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Selected {
|
pub struct Selected {
|
||||||
inner: HashSet<Url>,
|
inner: BTreeSet<Url>,
|
||||||
parents: HashMap<Url, usize>,
|
parents: HashMap<Url, usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Selected {
|
impl Deref for Selected {
|
||||||
type Target = HashSet<Url>;
|
type Target = BTreeSet<Url>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target { &self.inner }
|
fn deref(&self) -> &Self::Target { &self.inner }
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{collections::{hash_set, HashSet}, ops::Deref};
|
use std::{collections::{hash_set, BTreeSet}, ops::Deref};
|
||||||
|
|
||||||
use mlua::{AnyUserData, IntoLuaMulti, Lua, MetaMethod, UserDataMethods, UserDataRefMut};
|
use mlua::{AnyUserData, IntoLuaMulti, Lua, MetaMethod, UserDataMethods, UserDataRefMut};
|
||||||
use yazi_plugin::{bindings::Cast, url::Url};
|
use yazi_plugin::{bindings::Cast, url::Url};
|
||||||
@ -7,18 +7,18 @@ use super::{Iter, SCOPE};
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub(super) struct Selected {
|
pub(super) struct Selected {
|
||||||
inner: *const HashSet<yazi_shared::fs::Url>,
|
inner: *const BTreeSet<yazi_shared::fs::Url>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Selected {
|
impl Deref for Selected {
|
||||||
type Target = HashSet<yazi_shared::fs::Url>;
|
type Target = BTreeSet<yazi_shared::fs::Url>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target { self.inner() }
|
fn deref(&self) -> &Self::Target { self.inner() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Selected {
|
impl Selected {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn make(inner: &HashSet<yazi_shared::fs::Url>) -> mlua::Result<AnyUserData<'static>> {
|
pub(super) fn make(inner: &BTreeSet<yazi_shared::fs::Url>) -> mlua::Result<AnyUserData<'static>> {
|
||||||
SCOPE.create_any_userdata(Self { inner })
|
SCOPE.create_any_userdata(Self { inner })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,5 +45,5 @@ impl Selected {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn inner(&self) -> &'static HashSet<yazi_shared::fs::Url> { unsafe { &*self.inner } }
|
fn inner(&self) -> &'static BTreeSet<yazi_shared::fs::Url> { unsafe { &*self.inner } }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user