diff options
author | Blaž Hrastnik | 2020-09-05 13:01:05 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-09-07 02:21:26 +0000 |
commit | 579b6899f1fe7f0a06857c4528f55f316e2975e9 (patch) | |
tree | 1b850ba7f2abc1698763fc55cf7eebdad0fe9c8f /helix-core/src/transaction.rs | |
parent | e806446379db3f5c7e3bc6fd823ddd6969ed6f32 (diff) |
Work on insert mode.
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. |