|
|
@ -8,9 +8,10 @@ use std::{
|
|
|
|
use anyhow::bail;
|
|
|
|
use anyhow::bail;
|
|
|
|
use crossterm::event::{Event, KeyEvent};
|
|
|
|
use crossterm::event::{Event, KeyEvent};
|
|
|
|
use helix_core::{diagnostic::Severity, test, Selection, Transaction};
|
|
|
|
use helix_core::{diagnostic::Severity, test, Selection, Transaction};
|
|
|
|
|
|
|
|
use helix_loader;
|
|
|
|
use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
|
|
|
|
use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
|
|
|
|
use helix_view::{current_ref, doc, editor::LspConfig, input::parse_macro, Editor};
|
|
|
|
use helix_view::{current_ref, doc, editor::LspConfig, input::parse_macro, Editor};
|
|
|
|
use tempfile::NamedTempFile;
|
|
|
|
use tempfile::{NamedTempFile, TempPath};
|
|
|
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
|
|
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
|
|
|
|
|
|
|
|
|
|
|
/// Specify how to set up the input text with line feeds
|
|
|
|
/// Specify how to set up the input text with line feeds
|
|
|
@ -229,6 +230,22 @@ pub fn test_syntax_loader(overrides: Option<String>) -> helix_core::syntax::Load
|
|
|
|
helix_core::syntax::Loader::new(lang.try_into().unwrap()).unwrap()
|
|
|
|
helix_core::syntax::Loader::new(lang.try_into().unwrap()).unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn init_persistence_files() -> anyhow::Result<(TempPath, TempPath, TempPath)> {
|
|
|
|
|
|
|
|
let command_file = NamedTempFile::new()?;
|
|
|
|
|
|
|
|
let command_path = command_file.into_temp_path();
|
|
|
|
|
|
|
|
helix_loader::initialize_command_histfile(Some(command_path.to_path_buf()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let search_file = NamedTempFile::new()?;
|
|
|
|
|
|
|
|
let search_path = search_file.into_temp_path();
|
|
|
|
|
|
|
|
helix_loader::initialize_search_histfile(Some(search_path.to_path_buf()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let file_file = NamedTempFile::new()?;
|
|
|
|
|
|
|
|
let file_path = file_file.into_temp_path();
|
|
|
|
|
|
|
|
helix_loader::initialize_file_histfile(Some(file_path.to_path_buf()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok((command_path, search_path, file_path))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Use this for very simple test cases where there is one input
|
|
|
|
/// Use this for very simple test cases where there is one input
|
|
|
|
/// document, selection, and sequence of key presses, and you just
|
|
|
|
/// document, selection, and sequence of key presses, and you just
|
|
|
|
/// want to verify the resulting document and selection.
|
|
|
|
/// want to verify the resulting document and selection.
|
|
|
@ -236,6 +253,7 @@ pub async fn test_with_config<T: Into<TestCase>>(
|
|
|
|
app_builder: AppBuilder,
|
|
|
|
app_builder: AppBuilder,
|
|
|
|
test_case: T,
|
|
|
|
test_case: T,
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
) -> anyhow::Result<()> {
|
|
|
|
|
|
|
|
let (_, _, _) = init_persistence_files()?;
|
|
|
|
let test_case = test_case.into();
|
|
|
|
let test_case = test_case.into();
|
|
|
|
let app = app_builder.build()?;
|
|
|
|
let app = app_builder.build()?;
|
|
|
|
|
|
|
|
|
|
|
@ -345,7 +363,7 @@ impl AppBuilder {
|
|
|
|
path: P,
|
|
|
|
path: P,
|
|
|
|
pos: Option<helix_core::Position>,
|
|
|
|
pos: Option<helix_core::Position>,
|
|
|
|
) -> Self {
|
|
|
|
) -> Self {
|
|
|
|
self.args.files.push((path.into(), pos.unwrap_or_default()));
|
|
|
|
self.args.files.push((path.into(), pos));
|
|
|
|
self
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|