88//! API #1 (`editor.getNextKey()`) when used by a plugin that does
99//! NOT also use `defineMode` bindings.
1010
11- use crate :: common:: fixtures:: TestFixture ;
1211use crate :: common:: harness:: { copy_plugin, copy_plugin_lib, EditorTestHarness } ;
1312use crate :: common:: tracing:: init_tracing_from_env;
1413use crossterm:: event:: { KeyCode , KeyModifiers } ;
1514use std:: fs;
15+ use std:: path:: PathBuf ;
1616
1717/// Build a harness with the `flash` plugin loaded into an isolated
18- /// per-test project directory.
19- fn flash_harness ( width : u16 , height : u16 ) -> ( EditorTestHarness , tempfile:: TempDir ) {
18+ /// per-test project directory. Returns the harness, the TempDir
19+ /// guard (must outlive the harness), and the project root path —
20+ /// callers should put any test fixtures **under that root** so that
21+ /// the editor displays them with short relative paths in the status
22+ /// bar. Long absolute paths (like macOS `/private/var/folders/…`
23+ /// temp paths) push the rest of the status bar off the visible
24+ /// area, including the plugin's own `Flash[…]` text the tests wait
25+ /// on.
26+ fn flash_harness ( width : u16 , height : u16 ) -> ( EditorTestHarness , tempfile:: TempDir , PathBuf ) {
2027 init_tracing_from_env ( ) ;
2128 let temp_dir = tempfile:: TempDir :: new ( ) . unwrap ( ) ;
2229 let project_root = temp_dir. path ( ) . join ( "project_root" ) ;
@@ -31,10 +38,20 @@ fn flash_harness(width: u16, height: u16) -> (EditorTestHarness, tempfile::TempD
3138 width,
3239 height,
3340 Default :: default ( ) ,
34- project_root,
41+ project_root. clone ( ) ,
3542 )
3643 . unwrap ( ) ;
37- ( harness, temp_dir)
44+ ( harness, temp_dir, project_root)
45+ }
46+
47+ /// Write `content` to `name` inside the harness project root and
48+ /// return the resulting path. Use this in place of
49+ /// `TestFixture::new` so the file lives **under** the editor's
50+ /// working directory and renders with a short relative path.
51+ fn write_fixture ( project_root : & std:: path:: Path , name : & str , content : & str ) -> PathBuf {
52+ let path = project_root. join ( name) ;
53+ fs:: write ( & path, content) . unwrap ( ) ;
54+ path
3855}
3956
4057/// Open the command palette, type `Flash: Jump`, press Enter, and
@@ -92,9 +109,13 @@ fn flash_jumps_to_label() {
92109 // the assertion screen-only (CONTRIBUTING rule #2), we then
93110 // insert a marker character and observe where it lands in the
94111 // rendered buffer.
95- let ( mut harness, _temp) = flash_harness ( 120 , 24 ) ;
96- let fixture = TestFixture :: new ( "test.txt" , "hello world\n hello there\n hello again\n " ) . unwrap ( ) ;
97- harness. open_file ( & fixture. path ) . unwrap ( ) ;
112+ let ( mut harness, _temp, project_root) = flash_harness ( 120 , 24 ) ;
113+ let path = write_fixture (
114+ & project_root,
115+ "test.txt" ,
116+ "hello world\n hello there\n hello again\n " ,
117+ ) ;
118+ harness. open_file ( & path) . unwrap ( ) ;
98119 harness. render ( ) . unwrap ( ) ;
99120
100121 arm_flash ( & mut harness) ;
@@ -123,9 +144,13 @@ fn flash_jumps_to_label() {
123144
124145#[ test]
125146fn flash_escape_cancels_no_movement ( ) {
126- let ( mut harness, _temp) = flash_harness ( 120 , 24 ) ;
127- let fixture = TestFixture :: new ( "test.txt" , "hello world\n hello there\n hello again\n " ) . unwrap ( ) ;
128- harness. open_file ( & fixture. path ) . unwrap ( ) ;
147+ let ( mut harness, _temp, project_root) = flash_harness ( 120 , 24 ) ;
148+ let path = write_fixture (
149+ & project_root,
150+ "test.txt" ,
151+ "hello world\n hello there\n hello again\n " ,
152+ ) ;
153+ harness. open_file ( & path) . unwrap ( ) ;
129154 harness. render ( ) . unwrap ( ) ;
130155
131156 arm_flash ( & mut harness) ;
@@ -152,9 +177,13 @@ fn flash_backspace_shrinks_pattern() {
152177 // After Backspace the prior label set should be re-assigned.
153178 // Verify by typing a too-narrow pattern first ("there"), then
154179 // Backspacing back to a multi-match prefix and pressing a label.
155- let ( mut harness, _temp) = flash_harness ( 120 , 24 ) ;
156- let fixture = TestFixture :: new ( "test.txt" , "hello world\n hello there\n hello again\n " ) . unwrap ( ) ;
157- harness. open_file ( & fixture. path ) . unwrap ( ) ;
180+ let ( mut harness, _temp, project_root) = flash_harness ( 120 , 24 ) ;
181+ let path = write_fixture (
182+ & project_root,
183+ "test.txt" ,
184+ "hello world\n hello there\n hello again\n " ,
185+ ) ;
186+ harness. open_file ( & path) . unwrap ( ) ;
158187 harness. render ( ) . unwrap ( ) ;
159188
160189 arm_flash ( & mut harness) ;
@@ -207,9 +236,13 @@ fn flash_backspace_shrinks_pattern() {
207236fn flash_label_substitutes_rendered_glyph ( ) {
208237 // Same buffer shape as `flash_jumps_to_label` so the harness
209238 // setup that's already known to work doesn't surprise us.
210- let ( mut harness, _temp) = flash_harness ( 120 , 24 ) ;
211- let fixture = TestFixture :: new ( "test.txt" , "hello world\n hello there\n hello again\n " ) . unwrap ( ) ;
212- harness. open_file ( & fixture. path ) . unwrap ( ) ;
239+ let ( mut harness, _temp, project_root) = flash_harness ( 120 , 24 ) ;
240+ let path = write_fixture (
241+ & project_root,
242+ "test.txt" ,
243+ "hello world\n hello there\n hello again\n " ,
244+ ) ;
245+ harness. open_file ( & path) . unwrap ( ) ;
213246 harness. render ( ) . unwrap ( ) ;
214247
215248 arm_flash ( & mut harness) ;
@@ -273,13 +306,13 @@ fn flash_jumps_across_splits() {
273306 // each split. The active split's match sorts first (label "a"),
274307 // the other split's match second (label "s"). Pressing "s" must
275308 // (a) focus the other split and (b) place the cursor on its match.
276- let ( mut harness, _temp) = flash_harness ( 120 , 30 ) ;
309+ let ( mut harness, _temp, project_root ) = flash_harness ( 120 , 30 ) ;
277310
278- let temp_files = tempfile :: TempDir :: new ( ) . unwrap ( ) ;
279- let f1 = temp_files . path ( ) . join ( " left.txt" ) ;
280- let f2 = temp_files . path ( ) . join ( "right.txt" ) ;
281- fs :: write ( & f1 , "alpha left side\n " ) . unwrap ( ) ;
282- fs :: write ( & f2 , "alpha right side\n " ) . unwrap ( ) ;
311+ // Place both files **under** the harness project root so the
312+ // editor renders short relative paths (` left.txt` / `right.txt`)
313+ // in the status bar. See the comment on `flash_harness`.
314+ let f1 = write_fixture ( & project_root , "left.txt" , " alpha left side\n ") ;
315+ let f2 = write_fixture ( & project_root , "right.txt" , " alpha right side\n ") ;
283316
284317 // Open left file in initial split, then create a vertical split
285318 // and open right file in the new (active) split.
@@ -345,9 +378,13 @@ fn flash_jumps_across_splits() {
345378
346379#[ test]
347380fn flash_enter_jumps_to_closest ( ) {
348- let ( mut harness, _temp) = flash_harness ( 120 , 24 ) ;
349- let fixture = TestFixture :: new ( "test.txt" , "hello world\n hello there\n hello again\n " ) . unwrap ( ) ;
350- harness. open_file ( & fixture. path ) . unwrap ( ) ;
381+ let ( mut harness, _temp, project_root) = flash_harness ( 120 , 24 ) ;
382+ let path = write_fixture (
383+ & project_root,
384+ "test.txt" ,
385+ "hello world\n hello there\n hello again\n " ,
386+ ) ;
387+ harness. open_file ( & path) . unwrap ( ) ;
351388 harness. render ( ) . unwrap ( ) ;
352389
353390 arm_flash ( & mut harness) ;
0 commit comments