diff options
author | Michael Davis | 2022-10-10 19:56:26 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-10-11 03:17:32 +0000 |
commit | 0aedef03334dfc0cb2a723cce23abc5b4ca55a22 (patch) | |
tree | 17e017760f23147c821bb25b0af027c47b08f10b /helix-view | |
parent | d418f0795d8a33c83ad87c5530c4819d83da09ef (diff) |
Apply transactions to Views
This change adds View::apply calls for all Document::apply call-sites,
ensuring that changes to a document do not leave invalid entries in
the View's jumplist.
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/document.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index b6b2f664..631c540b 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -24,7 +24,7 @@ use helix_core::{ DEFAULT_LINE_ENDING, }; -use crate::{DocumentId, Editor, ViewId}; +use crate::{DocumentId, Editor, View, ViewId}; /// 8kB of buffer space for encoding and decoding `Rope`s. const BUF_SIZE: usize = 8192; @@ -601,7 +601,7 @@ impl Document { } /// Reload the document from its path. - pub fn reload(&mut self, view_id: ViewId) -> Result<(), Error> { + pub fn reload(&mut self, view: &mut View) -> Result<(), Error> { let encoding = &self.encoding; let path = self.path().filter(|path| path.exists()); @@ -617,8 +617,9 @@ impl Document { // This is not considered a modification of the contents of the file regardless // of the encoding. let transaction = helix_core::diff::compare_ropes(self.text(), &rope); - self.apply(&transaction, view_id); - self.append_changes_to_history(view_id); + self.apply(&transaction, view.id); + view.apply(&transaction, self); + self.append_changes_to_history(view.id); self.reset_modified(); self.detect_indent_and_line_ending(); @@ -862,9 +863,10 @@ impl Document { self.savepoint = Some(Transaction::new(self.text())); } - pub fn restore(&mut self, view_id: ViewId) { + pub fn restore(&mut self, view: &mut View) { if let Some(revert) = self.savepoint.take() { - self.apply(&revert, view_id); + self.apply(&revert, view.id); + view.apply(&revert, self); } } |