Uncomment a bunch of tests in the editor

This commit is contained in:
Piotr Osiewicz 2023-12-01 18:11:27 +01:00
parent e0ccaa60ff
commit 4c4ec221af
4 changed files with 802 additions and 802 deletions

View file

@ -6325,7 +6325,6 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
}); });
} }
//todo!(finish editor tests)
// #[gpui::test] // #[gpui::test]
// fn test_highlighted_ranges(cx: &mut TestAppContext) { // fn test_highlighted_ranges(cx: &mut TestAppContext) {
// init_test(cx, |_| {}); // init_test(cx, |_| {});

View file

@ -328,7 +328,7 @@ impl EditorElement {
}); });
} }
fn modifiers_changed( pub(crate) fn modifiers_changed(
editor: &mut Editor, editor: &mut Editor,
event: &ModifiersChangedEvent, event: &ModifiersChangedEvent,
cx: &mut ViewContext<Editor>, cx: &mut ViewContext<Editor>,

View file

@ -88,195 +88,195 @@ pub fn diff_hunk_to_display(hunk: DiffHunk<u32>, snapshot: &DisplaySnapshot) ->
} }
} }
// #[cfg(any(test, feature = "test_support"))] #[cfg(any(test, feature = "test_support"))]
// mod tests { mod tests {
// // use crate::editor_tests::init_test; use crate::editor_tests::init_test;
// use crate::Point; use crate::Point;
// use gpui::TestAppContext; use gpui::{Context, TestAppContext};
// use multi_buffer::{ExcerptRange, MultiBuffer}; use multi_buffer::{ExcerptRange, MultiBuffer};
// use project::{FakeFs, Project}; use project::{FakeFs, Project};
// use unindent::Unindent; use unindent::Unindent;
// #[gpui::test] #[gpui::test]
// async fn test_diff_hunks_in_range(cx: &mut TestAppContext) { async fn test_diff_hunks_in_range(cx: &mut TestAppContext) {
// use git::diff::DiffHunkStatus; use git::diff::DiffHunkStatus;
// init_test(cx, |_| {}); init_test(cx, |_| {});
// let fs = FakeFs::new(cx.background()); let fs = FakeFs::new(cx.background_executor.clone());
// let project = Project::test(fs, [], cx).await; let project = Project::test(fs, [], cx).await;
// // buffer has two modified hunks with two rows each // buffer has two modified hunks with two rows each
// let buffer_1 = project let buffer_1 = project
// .update(cx, |project, cx| { .update(cx, |project, cx| {
// project.create_buffer( project.create_buffer(
// " "
// 1.zero 1.zero
// 1.ONE 1.ONE
// 1.TWO 1.TWO
// 1.three 1.three
// 1.FOUR 1.FOUR
// 1.FIVE 1.FIVE
// 1.six 1.six
// " "
// .unindent() .unindent()
// .as_str(), .as_str(),
// None, None,
// cx, cx,
// ) )
// }) })
// .unwrap(); .unwrap();
// buffer_1.update(cx, |buffer, cx| { buffer_1.update(cx, |buffer, cx| {
// buffer.set_diff_base( buffer.set_diff_base(
// Some( Some(
// " "
// 1.zero 1.zero
// 1.one 1.one
// 1.two 1.two
// 1.three 1.three
// 1.four 1.four
// 1.five 1.five
// 1.six 1.six
// " "
// .unindent(), .unindent(),
// ), ),
// cx, cx,
// ); );
// }); });
// // buffer has a deletion hunk and an insertion hunk // buffer has a deletion hunk and an insertion hunk
// let buffer_2 = project let buffer_2 = project
// .update(cx, |project, cx| { .update(cx, |project, cx| {
// project.create_buffer( project.create_buffer(
// " "
// 2.zero 2.zero
// 2.one 2.one
// 2.two 2.two
// 2.three 2.three
// 2.four 2.four
// 2.five 2.five
// 2.six 2.six
// " "
// .unindent() .unindent()
// .as_str(), .as_str(),
// None, None,
// cx, cx,
// ) )
// }) })
// .unwrap(); .unwrap();
// buffer_2.update(cx, |buffer, cx| { buffer_2.update(cx, |buffer, cx| {
// buffer.set_diff_base( buffer.set_diff_base(
// Some( Some(
// " "
// 2.zero 2.zero
// 2.one 2.one
// 2.one-and-a-half 2.one-and-a-half
// 2.two 2.two
// 2.three 2.three
// 2.four 2.four
// 2.six 2.six
// " "
// .unindent(), .unindent(),
// ), ),
// cx, cx,
// ); );
// }); });
// cx.foreground().run_until_parked(); cx.background_executor.run_until_parked();
// let multibuffer = cx.add_model(|cx| { let multibuffer = cx.build_model(|cx| {
// let mut multibuffer = MultiBuffer::new(0); let mut multibuffer = MultiBuffer::new(0);
// multibuffer.push_excerpts( multibuffer.push_excerpts(
// buffer_1.clone(), buffer_1.clone(),
// [ [
// // excerpt ends in the middle of a modified hunk // excerpt ends in the middle of a modified hunk
// ExcerptRange { ExcerptRange {
// context: Point::new(0, 0)..Point::new(1, 5), context: Point::new(0, 0)..Point::new(1, 5),
// primary: Default::default(), primary: Default::default(),
// }, },
// // excerpt begins in the middle of a modified hunk // excerpt begins in the middle of a modified hunk
// ExcerptRange { ExcerptRange {
// context: Point::new(5, 0)..Point::new(6, 5), context: Point::new(5, 0)..Point::new(6, 5),
// primary: Default::default(), primary: Default::default(),
// }, },
// ], ],
// cx, cx,
// ); );
// multibuffer.push_excerpts( multibuffer.push_excerpts(
// buffer_2.clone(), buffer_2.clone(),
// [ [
// // excerpt ends at a deletion // excerpt ends at a deletion
// ExcerptRange { ExcerptRange {
// context: Point::new(0, 0)..Point::new(1, 5), context: Point::new(0, 0)..Point::new(1, 5),
// primary: Default::default(), primary: Default::default(),
// }, },
// // excerpt starts at a deletion // excerpt starts at a deletion
// ExcerptRange { ExcerptRange {
// context: Point::new(2, 0)..Point::new(2, 5), context: Point::new(2, 0)..Point::new(2, 5),
// primary: Default::default(), primary: Default::default(),
// }, },
// // excerpt fully contains a deletion hunk // excerpt fully contains a deletion hunk
// ExcerptRange { ExcerptRange {
// context: Point::new(1, 0)..Point::new(2, 5), context: Point::new(1, 0)..Point::new(2, 5),
// primary: Default::default(), primary: Default::default(),
// }, },
// // excerpt fully contains an insertion hunk // excerpt fully contains an insertion hunk
// ExcerptRange { ExcerptRange {
// context: Point::new(4, 0)..Point::new(6, 5), context: Point::new(4, 0)..Point::new(6, 5),
// primary: Default::default(), primary: Default::default(),
// }, },
// ], ],
// cx, cx,
// ); );
// multibuffer multibuffer
// }); });
// let snapshot = multibuffer.read_with(cx, |b, cx| b.snapshot(cx)); let snapshot = multibuffer.read_with(cx, |b, cx| b.snapshot(cx));
// assert_eq!( assert_eq!(
// snapshot.text(), snapshot.text(),
// " "
// 1.zero 1.zero
// 1.ONE 1.ONE
// 1.FIVE 1.FIVE
// 1.six 1.six
// 2.zero 2.zero
// 2.one 2.one
// 2.two 2.two
// 2.one 2.one
// 2.two 2.two
// 2.four 2.four
// 2.five 2.five
// 2.six" 2.six"
// .unindent() .unindent()
// ); );
// let expected = [ let expected = [
// (DiffHunkStatus::Modified, 1..2), (DiffHunkStatus::Modified, 1..2),
// (DiffHunkStatus::Modified, 2..3), (DiffHunkStatus::Modified, 2..3),
// //TODO: Define better when and where removed hunks show up at range extremities //TODO: Define better when and where removed hunks show up at range extremities
// (DiffHunkStatus::Removed, 6..6), (DiffHunkStatus::Removed, 6..6),
// (DiffHunkStatus::Removed, 8..8), (DiffHunkStatus::Removed, 8..8),
// (DiffHunkStatus::Added, 10..11), (DiffHunkStatus::Added, 10..11),
// ]; ];
// assert_eq!( assert_eq!(
// snapshot snapshot
// .git_diff_hunks_in_range(0..12) .git_diff_hunks_in_range(0..12)
// .map(|hunk| (hunk.status(), hunk.buffer_range)) .map(|hunk| (hunk.status(), hunk.buffer_range))
// .collect::<Vec<_>>(), .collect::<Vec<_>>(),
// &expected, &expected,
// ); );
// assert_eq!( assert_eq!(
// snapshot snapshot
// .git_diff_hunks_in_range_rev(0..12) .git_diff_hunks_in_range_rev(0..12)
// .map(|hunk| (hunk.status(), hunk.buffer_range)) .map(|hunk| (hunk.status(), hunk.buffer_range))
// .collect::<Vec<_>>(), .collect::<Vec<_>>(),
// expected expected
// .iter() .iter()
// .rev() .rev()
// .cloned() .cloned()
// .collect::<Vec<_>>() .collect::<Vec<_>>()
// .as_slice(), .as_slice(),
// ); );
// } }
// } }

File diff suppressed because it is too large Load diff