ElyMark: a merge taken from disk leaves the tab saved (M-03)
Every path that takes the disk text as saved goes through adopt_disk, which sets the tab's mark and the view's baseline together; the merge branch no longer repeats it by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
42bbc4e8fb
commit
d5f94e6e7a
6 files changed
+17
-22
No files matched your search
@@ -112,20 +112,10 @@ impl Desk {
|
||||
if open > 0 {
|
||||
return log::error!("mark: a merge with {open} open conflicts");
|
||||
}
|
||||
let Some(tab) = self.tab_mut(id) else {
|
||||
return;
|
||||
};
|
||||
if let Err(error) = tab.session.reload_at(fingerprint) {
|
||||
let why = error.to_string();
|
||||
return self.set_outside(id, Outside::Unread(why), cx);
|
||||
// Disk text is saved; the merge edits it.
|
||||
if let Some(view) = self.adopt_disk(id, &disk, fingerprint, cx) {
|
||||
view.update(cx, |view, cx| view.adopt(merged, cx));
|
||||
}
|
||||
tab.extra.base = disk.text.clone();
|
||||
tab.mark = crate::engine::mark(&disk.text);
|
||||
tab.extra.restart_autosave();
|
||||
tab.doc.lock().expect("the text lock").source = disk;
|
||||
let view = tab.view.clone();
|
||||
view.update(cx, |view, cx| view.adopt(merged, cx));
|
||||
self.set_outside(id, Outside::Clear, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,11 +236,7 @@ impl Desk {
|
||||
match (disk.text == current, dirty) {
|
||||
// The same text: only the file underneath is new.
|
||||
(true, _) => {
|
||||
if let Some(view) = self.adopt_disk(id, &disk, fingerprint, cx) {
|
||||
// What shows is now saved: the tab is clean.
|
||||
let saved = crate::engine::mark(&disk.text);
|
||||
view.update(cx, |view, cx| view.saved(&saved, cx));
|
||||
}
|
||||
self.adopt_disk(id, &disk, fingerprint, cx);
|
||||
}
|
||||
// The text as last saved: the edits stay unsaved.
|
||||
(false, true) if kept => self.keep_edits(id, disk, fingerprint, cx),
|
||||
@@ -294,8 +290,8 @@ impl Desk {
|
||||
self.save_after_pause(id, cx);
|
||||
}
|
||||
|
||||
/// The tab takes the file as saved; returns its view.
|
||||
fn adopt_disk(
|
||||
/// The tab and its view take the file as saved.
|
||||
pub(crate) fn adopt_disk(
|
||||
&mut self,
|
||||
id: u64,
|
||||
disk: &Source,
|
||||
@@ -309,7 +305,8 @@ impl Desk {
|
||||
}
|
||||
tab.extra.base = disk.text.clone();
|
||||
// The file holds the disk's text: it is saved.
|
||||
tab.mark = crate::engine::mark(&disk.text);
|
||||
let saved = crate::engine::mark(&disk.text);
|
||||
tab.mark = saved.clone();
|
||||
tab.extra.restart_autosave();
|
||||
// Its bytes (BOM, line ends) are what saves keep now.
|
||||
tab.doc.lock().expect("the text lock").source = disk.clone();
|
||||
@@ -322,6 +319,7 @@ impl Desk {
|
||||
log::warn!("mark: the replaced file did not register: {error}");
|
||||
}
|
||||
self.set_outside(id, Outside::Clear, cx);
|
||||
view.update(cx, |view, cx| view.saved(&saved, cx));
|
||||
Some(view)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user