Do not show diffs for files with \r\n contents (#11519)

This commit is contained in:
Kirill Bulatov 2024-05-08 00:37:09 +03:00 committed by GitHub
parent 6a64b732b6
commit 3d9f0087ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 56 additions and 33 deletions

View file

@ -97,7 +97,7 @@ use std::{
};
use task::static_source::{StaticSource, TrackedFile};
use terminals::Terminals;
use text::{Anchor, BufferId, LineEnding, Rope};
use text::{Anchor, BufferId, LineEnding};
use util::{
debug_panic, defer,
http::{HttpClient, Url},
@ -7559,11 +7559,7 @@ impl Project {
None
} else {
let relative_path = path.strip_prefix(&work_directory).ok()?;
repo_entry
.repo()
.lock()
.load_index_text(relative_path)
.map(Rope::from)
repo_entry.repo().lock().load_index_text(relative_path)
};
Some((buffer, base_text))
}
@ -7591,7 +7587,7 @@ impl Project {
.send(proto::UpdateDiffBase {
project_id,
buffer_id,
diff_base: diff_base.map(|rope| rope.to_string()),
diff_base,
})
.log_err();
}
@ -8666,14 +8662,15 @@ impl Project {
this.update(&mut cx, |this, cx| {
let buffer_id = envelope.payload.buffer_id;
let buffer_id = BufferId::new(buffer_id)?;
let diff_base = envelope.payload.diff_base.map(Rope::from);
if let Some(buffer) = this
.opened_buffers
.get_mut(&buffer_id)
.and_then(|b| b.upgrade())
.or_else(|| this.incomplete_remote_buffers.get(&buffer_id).cloned())
{
buffer.update(cx, |buffer, cx| buffer.set_diff_base(diff_base, cx));
buffer.update(cx, |buffer, cx| {
buffer.set_diff_base(envelope.payload.diff_base, cx)
});
}
Ok(())
})?