aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-05-28 08:47:35 +0000
committerBlaž Hrastnik2020-05-28 08:47:35 +0000
commit6905ff03c29c9fc020a6333adf9e9d5004c3f3c5 (patch)
tree39b0a23ccafce90cc7c767cee5859c75666fd3d6 /helix-core
parent1984410ac998ac5561f4a3de87d3d125f2f61178 (diff)
Start swapping from termwiz to crossterm + async.
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/state.rs6
-rw-r--r--helix-core/src/transaction.rs33
2 files changed, 12 insertions, 27 deletions
diff --git a/helix-core/src/state.rs b/helix-core/src/state.rs
index b4a3f2f0..22de6ca7 100644
--- a/helix-core/src/state.rs
+++ b/helix-core/src/state.rs
@@ -18,7 +18,11 @@ impl State {
// TODO: buf/selection accessors
- // update/transact
+ // update/transact:
+ // update(desc) => transaction ? transaction.doc() for applied doc
+ // transaction.apply(doc)
+ // doc.transact(fn -> ... end)
+
// replaceSelection (transaction that replaces selection)
// changeByRange
// changes
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 8da01c09..f3bb40fa 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -1,19 +1,3 @@
-// pub struct Change {
-// from: usize,
-// to: usize,
-// insert: Option<String>,
-// }
-
-// 40 bytes (8 + 24 + 8) -> strings are really big 24 as String, 16 as &str
-// pub struct Change {
-// /// old extent
-// old_extent: usize,
-// /// inserted text, new extent equal to insert length
-// insert: Option<String>,
-// /// distance from the previous change
-// distance: usize,
-// }
-
use crate::{Buffer, Rope, Selection, Tendril};
// TODO: divided into three different operations, I sort of like having just
@@ -33,11 +17,11 @@ pub enum Change {
Insert(Tendril),
}
-impl Change {
- pub fn new(from: usize, to: usize, insert: Option<Tendril>) {
- // old_extent, new_extent, insert
- }
-}
+// impl Change {
+// pub fn new(from: usize, to: usize, insert: Option<Tendril>) {
+// // old_extent, new_extent, insert
+// }
+// }
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Assoc {
@@ -46,13 +30,8 @@ pub enum Assoc {
}
// ChangeSpec = Change | ChangeSet | Vec<Change>
-// ChangeDesc as a ChangeSet without text: can't be applied, cheaper to store.
-// ChangeSet = ChangeDesc with Text
#[derive(Debug)]
pub struct ChangeSet {
- // basically Vec<ChangeDesc> where ChangeDesc = (current len, replacement len?)
- // (0, n>0) for insertion, (n>0, 0) for deletion, (>0, >0) for replacement
- // sections: Vec<(usize, isize)>,
changes: Vec<Change>,
/// The required document length. Will refuse to apply changes unless it matches.
len: usize,
@@ -341,6 +320,8 @@ pub struct Transaction {
// scroll_into_view
}
+impl Transaction {}
+
#[cfg(test)]
mod test {
use super::*;