Add fold_at_level test (#19800)
This commit is contained in:
parent
2e32f1c8a1
commit
c12a9f2673
1 changed files with 106 additions and 0 deletions
|
@ -1080,6 +1080,112 @@ fn test_fold_action_multiple_line_breaks(cx: &mut TestAppContext) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
fn test_fold_at_level(cx: &mut TestAppContext) {
|
||||||
|
init_test(cx, |_| {});
|
||||||
|
|
||||||
|
let view = cx.add_window(|cx| {
|
||||||
|
let buffer = MultiBuffer::build_simple(
|
||||||
|
&"
|
||||||
|
class Foo:
|
||||||
|
# Hello!
|
||||||
|
|
||||||
|
def a():
|
||||||
|
print(1)
|
||||||
|
|
||||||
|
def b():
|
||||||
|
print(2)
|
||||||
|
|
||||||
|
|
||||||
|
class Bar:
|
||||||
|
# World!
|
||||||
|
|
||||||
|
def a():
|
||||||
|
print(1)
|
||||||
|
|
||||||
|
def b():
|
||||||
|
print(2)
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
.unindent(),
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
build_editor(buffer.clone(), cx)
|
||||||
|
});
|
||||||
|
|
||||||
|
_ = view.update(cx, |view, cx| {
|
||||||
|
view.fold_at_level(&FoldAtLevel { level: 2 }, cx);
|
||||||
|
assert_eq!(
|
||||||
|
view.display_text(cx),
|
||||||
|
"
|
||||||
|
class Foo:
|
||||||
|
# Hello!
|
||||||
|
|
||||||
|
def a():⋯
|
||||||
|
|
||||||
|
def b():⋯
|
||||||
|
|
||||||
|
|
||||||
|
class Bar:
|
||||||
|
# World!
|
||||||
|
|
||||||
|
def a():⋯
|
||||||
|
|
||||||
|
def b():⋯
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
.unindent(),
|
||||||
|
);
|
||||||
|
|
||||||
|
view.fold_at_level(&FoldAtLevel { level: 1 }, cx);
|
||||||
|
assert_eq!(
|
||||||
|
view.display_text(cx),
|
||||||
|
"
|
||||||
|
class Foo:⋯
|
||||||
|
|
||||||
|
|
||||||
|
class Bar:⋯
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
.unindent(),
|
||||||
|
);
|
||||||
|
|
||||||
|
view.unfold_all(&UnfoldAll, cx);
|
||||||
|
view.fold_at_level(&FoldAtLevel { level: 0 }, cx);
|
||||||
|
assert_eq!(
|
||||||
|
view.display_text(cx),
|
||||||
|
"
|
||||||
|
class Foo:
|
||||||
|
# Hello!
|
||||||
|
|
||||||
|
def a():
|
||||||
|
print(1)
|
||||||
|
|
||||||
|
def b():
|
||||||
|
print(2)
|
||||||
|
|
||||||
|
|
||||||
|
class Bar:
|
||||||
|
# World!
|
||||||
|
|
||||||
|
def a():
|
||||||
|
print(1)
|
||||||
|
|
||||||
|
def b():
|
||||||
|
print(2)
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
.unindent(),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(view.display_text(cx), view.buffer.read(cx).read(cx).text());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_move_cursor(cx: &mut TestAppContext) {
|
fn test_move_cursor(cx: &mut TestAppContext) {
|
||||||
init_test(cx, |_| {});
|
init_test(cx, |_| {});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue