diff options
author | Dario Oddenino | 2022-10-28 01:31:28 +0000 |
---|---|---|
committer | GitHub | 2022-10-28 01:31:28 +0000 |
commit | 6752c7d3474289596c9e062f54beaf07011b6a40 (patch) | |
tree | 3a7860bacd1ad224c5d20788c716223440489d6d /helix-term/tests/test | |
parent | de5b100556ce4d9a2f739bd54904246f97dc6863 (diff) |
Trim quotes and braces from paths in goto_file_impl (#4370)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-term/tests/test')
-rw-r--r-- | helix-term/tests/test/commands.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index e24ee3e0..aadf104b 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -1,6 +1,7 @@ use std::ops::RangeInclusive; use helix_core::diagnostic::Severity; +use helix_term::application::Application; use super::*; @@ -133,3 +134,62 @@ async fn test_selection_duplication() -> anyhow::Result<()> { .await?; Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_goto_file_impl() -> anyhow::Result<()> { + let file = tempfile::NamedTempFile::new()?; + + fn match_paths(app: &Application, matches: Vec<&str>) -> usize { + app.editor + .documents() + .filter_map(|d| d.path()?.file_name()) + .filter(|n| matches.iter().any(|m| *m == n.to_string_lossy())) + .count() + } + + // Single selection + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("ione.js<esc>%gf"), + Some(&|app| { + assert_eq!(1, match_paths(app, vec!["one.js"])); + }), + false, + ) + .await?; + + // Multiple selection + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("ione.js<ret>two.js<esc>%<A-s>gf"), + Some(&|app| { + assert_eq!(2, match_paths(app, vec!["one.js", "two.js"])); + }), + false, + ) + .await?; + + // Cursor on first quote + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("iimport 'one.js'<esc>B;gf"), + Some(&|app| { + assert_eq!(1, match_paths(app, vec!["one.js"])); + }), + false, + ) + .await?; + + // Cursor on last quote + test_key_sequence( + &mut AppBuilder::new().with_file(file.path(), None).build()?, + Some("iimport 'one.js'<esc>bgf"), + Some(&|app| { + assert_eq!(1, match_paths(app, vec!["one.js"])); + }), + false, + ) + .await?; + + Ok(()) +} |