Assign base text language earlier to fix missing highlighting in deletion hunks (#24413)
Release Notes: - Fixed deletion diff hunks not being syntax highlighted in some cases Co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
5315d38cf4
commit
59bba2a98c
2 changed files with 56 additions and 32 deletions
|
@ -5776,6 +5776,9 @@ async fn test_uncommitted_diff_for_buffer(cx: &mut gpui::TestAppContext) {
|
|||
);
|
||||
|
||||
let project = Project::test(fs.clone(), ["/dir".as_ref()], cx).await;
|
||||
let language_registry = project.read_with(cx, |project, _| project.languages().clone());
|
||||
let language = rust_lang();
|
||||
language_registry.add(language.clone());
|
||||
|
||||
let buffer = project
|
||||
.update(cx, |project, cx| {
|
||||
|
@ -5790,13 +5793,23 @@ async fn test_uncommitted_diff_for_buffer(cx: &mut gpui::TestAppContext) {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
uncommitted_diff.read_with(cx, |diff, _| {
|
||||
assert_eq!(
|
||||
diff.snapshot
|
||||
.base_text
|
||||
.as_ref()
|
||||
.and_then(|base| base.language().cloned()),
|
||||
Some(language)
|
||||
)
|
||||
});
|
||||
|
||||
cx.run_until_parked();
|
||||
uncommitted_diff.update(cx, |uncommitted_diff, cx| {
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
assert_hunks(
|
||||
uncommitted_diff.diff_hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &snapshot),
|
||||
&snapshot,
|
||||
&uncommitted_diff.snapshot.base_text.as_ref().unwrap().text(),
|
||||
&uncommitted_diff.base_text_string().unwrap(),
|
||||
&[
|
||||
(0..1, "", "// print goodbye\n"),
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue