Fix 0 used in a count
This commit is contained in:
parent
c2c521015a
commit
7daed1b2c3
15 changed files with 73 additions and 29 deletions
|
@ -68,6 +68,8 @@ pub struct NeovimBackedTestContext<'a> {
|
|||
|
||||
last_set_state: Option<String>,
|
||||
recent_keystrokes: Vec<String>,
|
||||
|
||||
is_dirty: bool,
|
||||
}
|
||||
|
||||
impl<'a> NeovimBackedTestContext<'a> {
|
||||
|
@ -81,6 +83,7 @@ impl<'a> NeovimBackedTestContext<'a> {
|
|||
|
||||
last_set_state: None,
|
||||
recent_keystrokes: Default::default(),
|
||||
is_dirty: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,6 +131,7 @@ impl<'a> NeovimBackedTestContext<'a> {
|
|||
self.last_set_state = Some(marked_text.to_string());
|
||||
self.recent_keystrokes = Vec::new();
|
||||
self.neovim.set_state(marked_text).await;
|
||||
self.is_dirty = true;
|
||||
context_handle
|
||||
}
|
||||
|
||||
|
@ -153,6 +157,7 @@ impl<'a> NeovimBackedTestContext<'a> {
|
|||
}
|
||||
|
||||
pub async fn assert_shared_state(&mut self, marked_text: &str) {
|
||||
self.is_dirty = false;
|
||||
let marked_text = marked_text.replace("•", " ");
|
||||
let neovim = self.neovim_state().await;
|
||||
let editor = self.editor_state();
|
||||
|
@ -258,6 +263,7 @@ impl<'a> NeovimBackedTestContext<'a> {
|
|||
}
|
||||
|
||||
pub async fn assert_state_matches(&mut self) {
|
||||
self.is_dirty = false;
|
||||
let neovim = self.neovim_state().await;
|
||||
let editor = self.editor_state();
|
||||
let initial_state = self
|
||||
|
@ -383,6 +389,14 @@ impl<'a> DerefMut for NeovimBackedTestContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for NeovimBackedTestContext<'a> {
|
||||
fn drop(&mut self) {
|
||||
if self.is_dirty {
|
||||
panic!("Test context was dropped after set_shared_state before assert_shared_state")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use gpui::TestAppContext;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue