Indent guides (#11503)
Builds on top of existing work from #2249, but here's a showcase: https://github.com/zed-industries/zed/assets/53836821/4b346965-6654-496c-b379-75425d9b493f TODO: - [x] handle line wrapping - [x] implement handling in multibuffer (crashes currently) - [x] add configuration option - [x] new theme properties? What colors to use? - [x] Possibly support indents with different colors or background colors - [x] investigate edge cases (e.g. indent guides and folds continue on empty lines even if the next indent is different) - [x] add more tests (also test `find_active_indent_index`) - [x] docs (will do in a follow up PR) - [x] benchmark performance impact Release Notes: - Added indent guides ([#5373](https://github.com/zed-industries/zed/issues/5373)) --------- Co-authored-by: Nate Butler <1714999+iamnbutler@users.noreply.github.com> Co-authored-by: Remco <djsmits12@gmail.com>
This commit is contained in:
parent
3eb0418bda
commit
feea607bac
27 changed files with 1705 additions and 65 deletions
|
@ -2052,6 +2052,71 @@ fn test_serialization(cx: &mut gpui::AppContext) {
|
|||
assert_eq!(buffer2.read(cx).text(), "abcDF");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_find_matching_indent(cx: &mut TestAppContext) {
|
||||
cx.update(|cx| init_settings(cx, |_| {}));
|
||||
|
||||
async fn enclosing_indent(
|
||||
text: impl Into<String>,
|
||||
buffer_row: u32,
|
||||
cx: &mut TestAppContext,
|
||||
) -> Option<(Range<u32>, u32)> {
|
||||
let buffer = cx.new_model(|cx| Buffer::local(text, cx));
|
||||
let snapshot = cx.read(|cx| buffer.read(cx).snapshot());
|
||||
snapshot.enclosing_indent(buffer_row).await
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
enclosing_indent(
|
||||
"
|
||||
fn b() {
|
||||
if c {
|
||||
let d = 2;
|
||||
}
|
||||
}"
|
||||
.unindent(),
|
||||
1,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
Some((1..2, 4))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
enclosing_indent(
|
||||
"
|
||||
fn b() {
|
||||
if c {
|
||||
let d = 2;
|
||||
}
|
||||
}"
|
||||
.unindent(),
|
||||
2,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
Some((1..2, 4))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
enclosing_indent(
|
||||
"
|
||||
fn b() {
|
||||
if c {
|
||||
let d = 2;
|
||||
|
||||
let e = 5;
|
||||
}
|
||||
}"
|
||||
.unindent(),
|
||||
3,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
Some((1..4, 4))
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_collaboration(cx: &mut AppContext, mut rng: StdRng) {
|
||||
let min_peers = env::var("MIN_PEERS")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue