Fully qualify outside git-related code when a diff is a git diff

This commit is contained in:
Julia 2022-09-19 15:16:04 -04:00
parent 8edee9b2a8
commit b18dd8fcff
4 changed files with 38 additions and 37 deletions

View File

@ -274,7 +274,7 @@ impl FoldMap {
if buffer.edit_count() != new_buffer.edit_count()
|| buffer.parse_count() != new_buffer.parse_count()
|| buffer.diagnostics_update_count() != new_buffer.diagnostics_update_count()
|| buffer.diff_update_count() != new_buffer.diff_update_count()
|| buffer.git_diff_update_count() != new_buffer.git_diff_update_count()
|| buffer.trailing_excerpt_update_count()
!= new_buffer.trailing_excerpt_update_count()
{

View File

@ -1477,7 +1477,7 @@ impl Element for EditorElement {
let diff_hunks = snapshot
.buffer_snapshot
.diff_hunks_in_range(start_row..end_row)
.git_diff_hunks_in_range(start_row..end_row)
.collect();
let mut max_visible_line_width = 0.0;

View File

@ -91,7 +91,7 @@ struct BufferState {
last_selections_update_count: usize,
last_diagnostics_update_count: usize,
last_file_update_count: usize,
last_diff_update_count: usize,
last_git_diff_update_count: usize,
excerpts: Vec<ExcerptId>,
_subscriptions: [gpui::Subscription; 2],
}
@ -103,7 +103,7 @@ pub struct MultiBufferSnapshot {
parse_count: usize,
diagnostics_update_count: usize,
trailing_excerpt_update_count: usize,
diff_update_count: usize,
git_diff_update_count: usize,
edit_count: usize,
is_dirty: bool,
has_conflict: bool,
@ -205,7 +205,7 @@ impl MultiBuffer {
last_selections_update_count: buffer_state.last_selections_update_count,
last_diagnostics_update_count: buffer_state.last_diagnostics_update_count,
last_file_update_count: buffer_state.last_file_update_count,
last_diff_update_count: buffer_state.last_diff_update_count,
last_git_diff_update_count: buffer_state.last_git_diff_update_count,
excerpts: buffer_state.excerpts.clone(),
_subscriptions: [
new_cx.observe(&buffer_state.buffer, |_, _, cx| cx.notify()),
@ -842,7 +842,7 @@ impl MultiBuffer {
last_selections_update_count: buffer_snapshot.selections_update_count(),
last_diagnostics_update_count: buffer_snapshot.diagnostics_update_count(),
last_file_update_count: buffer_snapshot.file_update_count(),
last_diff_update_count: buffer_snapshot.diff_update_count(),
last_git_diff_update_count: buffer_snapshot.git_diff_update_count(),
excerpts: Default::default(),
_subscriptions: [
cx.observe(&buffer, |_, _, cx| cx.notify()),
@ -1265,7 +1265,7 @@ impl MultiBuffer {
let mut excerpts_to_edit = Vec::new();
let mut reparsed = false;
let mut diagnostics_updated = false;
let mut diff_updated = false;
let mut git_diff_updated = false;
let mut is_dirty = false;
let mut has_conflict = false;
let mut edited = false;
@ -1277,7 +1277,7 @@ impl MultiBuffer {
let selections_update_count = buffer.selections_update_count();
let diagnostics_update_count = buffer.diagnostics_update_count();
let file_update_count = buffer.file_update_count();
let diff_update_count = buffer.diff_update_count();
let git_diff_update_count = buffer.git_diff_update_count();
let buffer_edited = version.changed_since(&buffer_state.last_version);
let buffer_reparsed = parse_count > buffer_state.last_parse_count;
@ -1286,20 +1286,21 @@ impl MultiBuffer {
let buffer_diagnostics_updated =
diagnostics_update_count > buffer_state.last_diagnostics_update_count;
let buffer_file_updated = file_update_count > buffer_state.last_file_update_count;
let buffer_diff_updated = diff_update_count > buffer_state.last_diff_update_count;
let buffer_git_diff_updated =
git_diff_update_count > buffer_state.last_git_diff_update_count;
if buffer_edited
|| buffer_reparsed
|| buffer_selections_updated
|| buffer_diagnostics_updated
|| buffer_file_updated
|| buffer_diff_updated
|| buffer_git_diff_updated
{
buffer_state.last_version = version;
buffer_state.last_parse_count = parse_count;
buffer_state.last_selections_update_count = selections_update_count;
buffer_state.last_diagnostics_update_count = diagnostics_update_count;
buffer_state.last_file_update_count = file_update_count;
buffer_state.last_diff_update_count = diff_update_count;
buffer_state.last_git_diff_update_count = git_diff_update_count;
excerpts_to_edit.extend(
buffer_state
.excerpts
@ -1311,7 +1312,7 @@ impl MultiBuffer {
edited |= buffer_edited;
reparsed |= buffer_reparsed;
diagnostics_updated |= buffer_diagnostics_updated;
diff_updated |= buffer_diff_updated;
git_diff_updated |= buffer_git_diff_updated;
is_dirty |= buffer.is_dirty();
has_conflict |= buffer.has_conflict();
}
@ -1324,8 +1325,8 @@ impl MultiBuffer {
if diagnostics_updated {
snapshot.diagnostics_update_count += 1;
}
if diff_updated {
snapshot.diff_update_count += 1;
if git_diff_updated {
snapshot.git_diff_update_count += 1;
}
snapshot.is_dirty = is_dirty;
snapshot.has_conflict = has_conflict;
@ -2504,8 +2505,8 @@ impl MultiBufferSnapshot {
self.diagnostics_update_count
}
pub fn diff_update_count(&self) -> usize {
self.diff_update_count
pub fn git_diff_update_count(&self) -> usize {
self.git_diff_update_count
}
pub fn trailing_excerpt_update_count(&self) -> usize {
@ -2558,13 +2559,13 @@ impl MultiBufferSnapshot {
})
}
pub fn diff_hunks_in_range<'a>(
pub fn git_diff_hunks_in_range<'a>(
&'a self,
row_range: Range<u32>,
) -> impl 'a + Iterator<Item = DiffHunk<u32>> {
self.as_singleton()
.into_iter()
.flat_map(move |(_, _, buffer)| buffer.diff_hunks_in_range(row_range.clone()))
.flat_map(move |(_, _, buffer)| buffer.git_diff_hunks_in_range(row_range.clone()))
}
pub fn range_for_syntax_ancestor<T: ToOffset>(&self, range: Range<T>) -> Option<Range<usize>> {

View File

@ -1,4 +1,4 @@
use crate::git::{BufferDiff, DiffHunk};
use crate::git;
pub use crate::{
diagnostic_set::DiagnosticSet,
highlight_map::{HighlightId, HighlightMap},
@ -49,7 +49,7 @@ pub use lsp::DiagnosticSeverity;
pub struct Buffer {
text: TextBuffer,
head_text: Option<Arc<String>>,
git_diff: BufferDiff,
git_diff: git::BufferDiff,
file: Option<Arc<dyn File>>,
saved_version: clock::Global,
saved_version_fingerprint: String,
@ -69,7 +69,7 @@ pub struct Buffer {
diagnostics_update_count: usize,
diagnostics_timestamp: clock::Lamport,
file_update_count: usize,
diff_update_count: usize,
git_diff_update_count: usize,
completion_triggers: Vec<String>,
completion_triggers_timestamp: clock::Lamport,
deferred_ops: OperationQueue<Operation>,
@ -77,13 +77,13 @@ pub struct Buffer {
pub struct BufferSnapshot {
text: text::BufferSnapshot,
pub diff_snapshot: BufferDiff,
pub git_diff_snapshot: git::BufferDiff,
pub(crate) syntax: SyntaxSnapshot,
file: Option<Arc<dyn File>>,
diagnostics: DiagnosticSet,
diagnostics_update_count: usize,
file_update_count: usize,
diff_update_count: usize,
git_diff_update_count: usize,
remote_selections: TreeMap<ReplicaId, SelectionSet>,
selections_update_count: usize,
language: Option<Arc<Language>>,
@ -433,7 +433,7 @@ impl Buffer {
was_dirty_before_starting_transaction: None,
text: buffer,
head_text,
git_diff: BufferDiff::new(),
git_diff: git::BufferDiff::new(),
file,
syntax_map: Mutex::new(SyntaxMap::new()),
parsing_in_background: false,
@ -448,7 +448,7 @@ impl Buffer {
diagnostics_update_count: 0,
diagnostics_timestamp: Default::default(),
file_update_count: 0,
diff_update_count: 0,
git_diff_update_count: 0,
completion_triggers: Default::default(),
completion_triggers_timestamp: Default::default(),
deferred_ops: OperationQueue::new(),
@ -464,13 +464,13 @@ impl Buffer {
BufferSnapshot {
text,
syntax,
diff_snapshot: self.git_diff.clone(),
git_diff_snapshot: self.git_diff.clone(),
file: self.file.clone(),
remote_selections: self.remote_selections.clone(),
diagnostics: self.diagnostics.clone(),
diagnostics_update_count: self.diagnostics_update_count,
file_update_count: self.file_update_count,
diff_update_count: self.diff_update_count,
git_diff_update_count: self.git_diff_update_count,
language: self.language.clone(),
parse_count: self.parse_count,
selections_update_count: self.selections_update_count,
@ -672,7 +672,7 @@ impl Buffer {
if let Some(this) = this.upgrade(&cx) {
this.update(&mut cx, |this, cx| {
this.git_diff = buffer_diff;
this.diff_update_count += 1;
this.git_diff_update_count += 1;
cx.notify();
})
}
@ -705,8 +705,8 @@ impl Buffer {
self.file_update_count
}
pub fn diff_update_count(&self) -> usize {
self.diff_update_count
pub fn git_diff_update_count(&self) -> usize {
self.git_diff_update_count
}
#[cfg(any(test, feature = "test-support"))]
@ -2191,11 +2191,11 @@ impl BufferSnapshot {
})
}
pub fn diff_hunks_in_range<'a>(
pub fn git_diff_hunks_in_range<'a>(
&'a self,
query_row_range: Range<u32>,
) -> impl 'a + Iterator<Item = DiffHunk<u32>> {
self.diff_snapshot.hunks_in_range(query_row_range, self)
) -> impl 'a + Iterator<Item = git::DiffHunk<u32>> {
self.git_diff_snapshot.hunks_in_range(query_row_range, self)
}
pub fn diagnostics_in_range<'a, T, O>(
@ -2246,8 +2246,8 @@ impl BufferSnapshot {
self.file_update_count
}
pub fn diff_update_count(&self) -> usize {
self.diff_update_count
pub fn git_diff_update_count(&self) -> usize {
self.git_diff_update_count
}
}
@ -2275,7 +2275,7 @@ impl Clone for BufferSnapshot {
fn clone(&self) -> Self {
Self {
text: self.text.clone(),
diff_snapshot: self.diff_snapshot.clone(),
git_diff_snapshot: self.git_diff_snapshot.clone(),
syntax: self.syntax.clone(),
file: self.file.clone(),
remote_selections: self.remote_selections.clone(),
@ -2283,7 +2283,7 @@ impl Clone for BufferSnapshot {
selections_update_count: self.selections_update_count,
diagnostics_update_count: self.diagnostics_update_count,
file_update_count: self.file_update_count,
diff_update_count: self.diff_update_count,
git_diff_update_count: self.git_diff_update_count,
language: self.language.clone(),
parse_count: self.parse_count,
}