diff options
Diffstat (limited to 'helix-core/src/transaction.rs')
-rw-r--r-- | helix-core/src/transaction.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs index 1619a4db..2d8afc9b 100644 --- a/helix-core/src/transaction.rs +++ b/helix-core/src/transaction.rs @@ -47,6 +47,18 @@ impl ChangeSet { } } + pub fn insert(buf: &Buffer, pos: usize, c: char) -> Self { + let len = buf.contents.len_chars(); + Self { + changes: vec![ + Change::Retain(pos), + Change::Insert(Tendril::from_char(c)), + Change::Retain(len - pos), + ], + len, + } + } + // TODO: from iter /// Combine two changesets together. |