From d23ed3bfe439131004cf8c247fb4b4600fa92aff Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Sat, 6 Dec 2025 13:33:32 +0000 Subject: fix(selectable): prevent clash with other's custom operations - Make the `global_selection` operation check for the new `IndependentSelection` when trying to downcast_mut. - `IndependentSelection` uses wraps a `RefCell` so it can change its inner value. Theres some helper methods to create this `IndependentSelection` from an existing value and to then get the changed value once the operation is done. This way the `Text` and `Rich` simply need to pass this `IndependentSelection` to the operation `custom` method which will make sure it wont clash with any other custom operations that could be using `&mut bool` as well. --- src/text/rich.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/text') diff --git a/src/text/rich.rs b/src/text/rich.rs index b49adbd..eb8b6b2 100644 --- a/src/text/rich.rs +++ b/src/text/rich.rs @@ -954,12 +954,11 @@ where } } - // let mut isel = crate::operation::IndependentSelection::new(&mut self.independent_selection); - operation.custom( - None, - layout.bounds(), - &mut self.independent_selection, + let mut isel = crate::operation::IndependentSelection::new( + self.independent_selection, ); + operation.custom(None, layout.bounds(), &mut isel); + self.independent_selection = isel.get(); } fn mouse_interaction( -- cgit v1.2.3