vim: Fix linewise copy of last line with no trailing newline

Along the way, delete the VimBindingTestContext by updating the
visual tests to no-longer need it.
This commit is contained in:
Conrad Irwin 2023-08-23 23:45:42 -06:00
parent 26c3312049
commit e4794e3134
7 changed files with 118 additions and 187 deletions

View file

@ -1,64 +0,0 @@
use std::ops::{Deref, DerefMut};
use crate::*;
use super::VimTestContext;
pub struct VimBindingTestContext<'a, const COUNT: usize> {
cx: VimTestContext<'a>,
keystrokes_under_test: [&'static str; COUNT],
mode_before: Mode,
mode_after: Mode,
}
impl<'a, const COUNT: usize> VimBindingTestContext<'a, COUNT> {
pub fn new(
keystrokes_under_test: [&'static str; COUNT],
mode_before: Mode,
mode_after: Mode,
cx: VimTestContext<'a>,
) -> Self {
Self {
cx,
keystrokes_under_test,
mode_before,
mode_after,
}
}
pub fn binding<const NEW_COUNT: usize>(
self,
keystrokes_under_test: [&'static str; NEW_COUNT],
) -> VimBindingTestContext<'a, NEW_COUNT> {
VimBindingTestContext {
keystrokes_under_test,
cx: self.cx,
mode_before: self.mode_before,
mode_after: self.mode_after,
}
}
pub fn assert(&mut self, initial_state: &str, state_after: &str) {
self.cx.assert_binding(
self.keystrokes_under_test,
initial_state,
self.mode_before,
state_after,
self.mode_after,
)
}
}
impl<'a, const COUNT: usize> Deref for VimBindingTestContext<'a, COUNT> {
type Target = VimTestContext<'a>;
fn deref(&self) -> &Self::Target {
&self.cx
}
}
impl<'a, const COUNT: usize> DerefMut for VimBindingTestContext<'a, COUNT> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.cx
}
}

View file

@ -8,8 +8,6 @@ use search::{BufferSearchBar, ProjectSearchBar};
use crate::{state::Operator, *};
use super::VimBindingTestContext;
pub struct VimTestContext<'a> {
cx: EditorLspTestContext<'a>,
}
@ -126,14 +124,6 @@ impl<'a> VimTestContext<'a> {
assert_eq!(self.mode(), mode_after, "{}", self.assertion_context());
assert_eq!(self.active_operator(), None, "{}", self.assertion_context());
}
pub fn binding<const COUNT: usize>(
mut self,
keystrokes: [&'static str; COUNT],
) -> VimBindingTestContext<'a, COUNT> {
let mode = self.mode();
VimBindingTestContext::new(keystrokes, mode, mode, self)
}
}
impl<'a> Deref for VimTestContext<'a> {