diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1db7cc3e69061dac7a66d241079d36fba58a1c13..b396337e013e38243bfad077a5c4930b98fe6412 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5060,7 +5060,7 @@ impl Editor { cx.notify(); } - fn transact( + pub fn transact( &mut self, cx: &mut ViewContext, update: impl FnOnce(&mut Self, &mut ViewContext), diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index c33a96a94b8fb0efa030e6d82b38cb32deaa9c54..1302d54067810653140367b40966e869edcf8372 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -893,6 +893,52 @@ mod tests { (file3.clone(), DisplayPoint::new(0, 0)) ); + // Modify file to remove nav history location, and ensure duplicates are skipped + editor1.update(cx, |editor, cx| { + editor.select_display_ranges(&[DisplayPoint::new(15, 0)..DisplayPoint::new(15, 0)], cx) + }); + + for _ in 0..5 { + editor1.update(cx, |editor, cx| { + editor + .select_display_ranges(&[DisplayPoint::new(3, 0)..DisplayPoint::new(3, 0)], cx); + }); + editor1.update(cx, |editor, cx| { + editor.select_display_ranges( + &[DisplayPoint::new(13, 0)..DisplayPoint::new(13, 0)], + cx, + ) + }); + } + + editor1.update(cx, |editor, cx| { + editor.transact(cx, |editor, cx| { + editor.select_display_ranges( + &[DisplayPoint::new(2, 0)..DisplayPoint::new(14, 0)], + cx, + ); + editor.insert("", cx); + }) + }); + + editor1.update(cx, |editor, cx| { + editor.select_display_ranges(&[DisplayPoint::new(1, 0)..DisplayPoint::new(1, 0)], cx) + }); + workspace + .update(cx, |w, cx| Pane::go_back(w, None, cx)) + .await; + assert_eq!( + active_location(&workspace, cx), + (file1.clone(), DisplayPoint::new(2, 0)) + ); + workspace + .update(cx, |w, cx| Pane::go_back(w, None, cx)) + .await; + assert_eq!( + active_location(&workspace, cx), + (file1.clone(), DisplayPoint::new(3, 0)) + ); + fn active_location( workspace: &ViewHandle, cx: &mut TestAppContext,