Fix two issues with diff highlights (#24309)
* fix syntax highlighting of deleted text when buffer language changes * do not highlight entire untracked files as created, except in the project diff view Release Notes: - N/A Co-authored-by: ConradIrwin <conrad.irwin@gmail.com> Co-authored-by: cole-miller <m@cole-miller.net>
This commit is contained in:
parent
9114ca973c
commit
ca01a8b9cb
5 changed files with 126 additions and 52 deletions
|
@ -9,7 +9,7 @@ use gpui::{
|
|||
actions, AnyElement, AnyView, App, AppContext, AsyncWindowContext, Entity, EventEmitter,
|
||||
FocusHandle, Focusable, Render, Subscription, Task, WeakEntity,
|
||||
};
|
||||
use language::{Anchor, Buffer, Capability, OffsetRangeExt};
|
||||
use language::{Anchor, Buffer, Capability, OffsetRangeExt, Point};
|
||||
use multi_buffer::{MultiBuffer, PathKey};
|
||||
use project::{buffer_store::BufferChangeSet, git::GitState, Project, ProjectPath};
|
||||
use theme::ActiveTheme;
|
||||
|
@ -293,11 +293,15 @@ impl ProjectDiff {
|
|||
let change_set = diff_buffer.change_set;
|
||||
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
let diff_hunk_ranges = change_set
|
||||
.read(cx)
|
||||
.diff_hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &snapshot)
|
||||
.map(|diff_hunk| diff_hunk.buffer_range.to_point(&snapshot))
|
||||
.collect::<Vec<_>>();
|
||||
let change_set = change_set.read(cx);
|
||||
let diff_hunk_ranges = if change_set.base_text.is_none() {
|
||||
vec![Point::zero()..snapshot.max_point()]
|
||||
} else {
|
||||
change_set
|
||||
.diff_hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &snapshot)
|
||||
.map(|diff_hunk| diff_hunk.buffer_range.to_point(&snapshot))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
self.multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.set_excerpts_for_path(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue