|
|
@ -81,8 +81,10 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
|
|
|
|
test_fn: &dyn Fn(&Application),
|
|
|
|
test_fn: &dyn Fn(&Application),
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
let test_case = test_case.into();
|
|
|
|
let test_case = test_case.into();
|
|
|
|
let mut app =
|
|
|
|
let mut app = match app {
|
|
|
|
app.unwrap_or_else(|| Application::new(Args::default(), Config::default()).unwrap());
|
|
|
|
Some(app) => app,
|
|
|
|
|
|
|
|
None => Application::new(Args::default(), Config::default())?,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let (view, doc) = helix_view::current!(app.editor);
|
|
|
|
let (view, doc) = helix_view::current!(app.editor);
|
|
|
|
let sel = doc.selection(view.id).clone();
|
|
|
|
let sel = doc.selection(view.id).clone();
|
|
|
@ -108,7 +110,7 @@ pub async fn test_key_sequence_text_result<T: Into<TestCase>>(
|
|
|
|
test_case: T,
|
|
|
|
test_case: T,
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
let test_case = test_case.into();
|
|
|
|
let test_case = test_case.into();
|
|
|
|
let app = Application::new(args, config).unwrap();
|
|
|
|
let app = Application::new(args, config)?;
|
|
|
|
|
|
|
|
|
|
|
|
test_key_sequence_with_input_text(Some(app), test_case.clone(), &|app| {
|
|
|
|
test_key_sequence_with_input_text(Some(app), test_case.clone(), &|app| {
|
|
|
|
let doc = doc!(app.editor);
|
|
|
|
let doc = doc!(app.editor);
|
|
|
@ -123,13 +125,16 @@ pub async fn test_key_sequence_text_result<T: Into<TestCase>>(
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn temp_file_with_contents<S: AsRef<str>>(content: S) -> tempfile::NamedTempFile {
|
|
|
|
pub fn temp_file_with_contents<S: AsRef<str>>(
|
|
|
|
let mut temp_file = tempfile::NamedTempFile::new().unwrap();
|
|
|
|
content: S,
|
|
|
|
|
|
|
|
) -> anyhow::Result<tempfile::NamedTempFile> {
|
|
|
|
|
|
|
|
let mut temp_file = tempfile::NamedTempFile::new()?;
|
|
|
|
|
|
|
|
|
|
|
|
temp_file
|
|
|
|
temp_file
|
|
|
|
.as_file_mut()
|
|
|
|
.as_file_mut()
|
|
|
|
.write_all(content.as_ref().as_bytes())
|
|
|
|
.write_all(content.as_ref().as_bytes())?;
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
temp_file.flush().unwrap();
|
|
|
|
temp_file.flush()?;
|
|
|
|
temp_file.as_file_mut().sync_all().unwrap();
|
|
|
|
temp_file.as_file_mut().sync_all()?;
|
|
|
|
temp_file
|
|
|
|
Ok(temp_file)
|
|
|
|
}
|
|
|
|
}
|
|
|
|