Rework diff rendering to allow putting the cursor into deleted text, soft-wrapping and scrolling deleted text correctly (#22994)
Closes #12553 * [x] Fix `diff_hunk_before` * [x] Fix failure to show deleted text when expanding hunk w/ cursor on second line of the hunk * [x] Failure to expand diff hunk below the cursor. * [x] Delete the whole file, and expand the diff. Backspace over the deleted hunk, panic! * [x] Go-to-line now counts the diff hunks, but it should not * [x] backspace at the beginning of a deleted hunk deletes too much text * [x] Indent guides are rendered incorrectly * [ ] Fix randomized multi buffer tests Maybe: * [ ] Buffer search should include deleted text (in vim mode it turns out I use `/x` all the time to jump to the next x I can see). * [ ] vim: should refuse to switch into insert mode if selection is fully within a diff. * [ ] vim `o` command when cursor is on last line of deleted hunk. * [ ] vim `shift-o` on first line of deleted hunk moves cursor but doesn't insert line * [x] `enter` at end of diff hunk inserts a new line but doesn't move cursor * [x] (`shift-enter` at start of diff hunk does nothing) * [ ] Inserting a line just before an expanded hunk collapses it Release Notes: - Improved diff rendering, allowing you to navigate with your cursor inside of deleted text in diff hunks. --------- Co-authored-by: Conrad <conrad@zed.dev> Co-authored-by: Cole <cole@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> Co-authored-by: Michael <michael@zed.dev> Co-authored-by: Agus <agus@zed.dev> Co-authored-by: João <joao@zed.dev>
This commit is contained in:
parent
1fdae4bae0
commit
d2c55cbe3d
64 changed files with 7653 additions and 5495 deletions
|
@ -21,7 +21,7 @@ use std::{
|
|||
};
|
||||
use syntax_map::TreeSitterOptions;
|
||||
use text::network::Network;
|
||||
use text::{BufferId, LineEnding, LineIndent};
|
||||
use text::{BufferId, LineEnding};
|
||||
use text::{Point, ToPoint};
|
||||
use unindent::Unindent as _;
|
||||
use util::{assert_set_eq, post_inc, test::marked_text_ranges, RandomCharIter};
|
||||
|
@ -2475,92 +2475,6 @@ 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>, LineIndent)> {
|
||||
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,
|
||||
LineIndent {
|
||||
tabs: 0,
|
||||
spaces: 4,
|
||||
line_blank: false,
|
||||
}
|
||||
))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
enclosing_indent(
|
||||
"
|
||||
fn b() {
|
||||
if c {
|
||||
let d = 2;
|
||||
}
|
||||
}"
|
||||
.unindent(),
|
||||
2,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
Some((
|
||||
1..2,
|
||||
LineIndent {
|
||||
tabs: 0,
|
||||
spaces: 4,
|
||||
line_blank: false,
|
||||
}
|
||||
))
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
enclosing_indent(
|
||||
"
|
||||
fn b() {
|
||||
if c {
|
||||
let d = 2;
|
||||
|
||||
let e = 5;
|
||||
}
|
||||
}"
|
||||
.unindent(),
|
||||
3,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
Some((
|
||||
1..4,
|
||||
LineIndent {
|
||||
tabs: 0,
|
||||
spaces: 4,
|
||||
line_blank: false,
|
||||
}
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_branch_and_merge(cx: &mut TestAppContext) {
|
||||
cx.update(|cx| init_settings(cx, |_| {}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue