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};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Selected {
|
||||
inner: HashSet<Url>,
|
||||
inner: BTreeSet<Url>,
|
||||
parents: HashMap<Url, usize>,
|
||||
}
|
||||
|
||||
impl Deref for Selected {
|
||||
type Target = HashSet<Url>;
|
||||
type Target = BTreeSet<Url>;
|
||||
|
||||
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 yazi_plugin::{bindings::Cast, url::Url};
|
||||
@ -7,18 +7,18 @@ use super::{Iter, SCOPE};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) struct Selected {
|
||||
inner: *const HashSet<yazi_shared::fs::Url>,
|
||||
inner: *const BTreeSet<yazi_shared::fs::Url>,
|
||||
}
|
||||
|
||||
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() }
|
||||
}
|
||||
|
||||
impl Selected {
|
||||
#[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 })
|
||||
}
|
||||
|
||||
@ -45,5 +45,5 @@ impl Selected {
|
||||
}
|
||||
|
||||
#[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