Merge pull request #2176 from zed-industries/better-move-to-brackets

Make jump to matching bracket action more predictable
This commit is contained in:
Kay Simmons
2023-02-15 14:32:51 -08:00
committed by GitHub
15 changed files with 460 additions and 218 deletions
+7 -4
View File
@@ -1,11 +1,15 @@
#[cfg(any(test, feature = "test-support"))]
use std::sync::Arc;
use lazy_static::lazy_static;
#[cfg(any(test, feature = "test-support"))]
use parking_lot::Mutex;
use collections::{hash_map::Entry, HashMap, HashSet};
use crate::{util::post_inc, ElementStateId};
#[cfg(any(test, feature = "test-support"))]
use crate::util::post_inc;
use crate::ElementStateId;
lazy_static! {
static ref LEAK_BACKTRACE: bool =
@@ -30,9 +34,8 @@ pub struct RefCounts {
}
impl RefCounts {
pub fn new(
#[cfg(any(test, feature = "test-support"))] leak_detector: Arc<Mutex<LeakDetector>>,
) -> Self {
#[cfg(any(test, feature = "test-support"))]
pub fn new(leak_detector: Arc<Mutex<LeakDetector>>) -> Self {
Self {
#[cfg(any(test, feature = "test-support"))]
leak_detector,
+5
View File
@@ -621,6 +621,8 @@ impl<T: View> ViewHandle<T> {
}
}
/// Tracks string context to be printed when assertions fail.
/// Often this is done by storing a context string in the manager and returning the handle.
#[derive(Clone)]
pub struct AssertionContextManager {
id: Arc<AtomicUsize>,
@@ -651,6 +653,9 @@ impl AssertionContextManager {
}
}
/// Used to track the lifetime of a piece of context so that it can be provided when an assertion fails.
/// For example, in the EditorTestContext, `set_state` returns a context handle so that if an assertion fails,
/// the state that was set initially for the failure can be printed in the error message
pub struct ContextHandle {
id: usize,
manager: AssertionContextManager,