From f2d62d446a7b1e03ef14b580e2aca0fad8aa23ef Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 5 Jul 2022 13:31:46 +0200 Subject: Refactor to do some to dos --- src/util/edit_map.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/edit_map.rs b/src/util/edit_map.rs index eba667d..ebc20b7 100644 --- a/src/util/edit_map.rs +++ b/src/util/edit_map.rs @@ -67,6 +67,7 @@ impl EditMap { pub fn add(&mut self, index: usize, remove: usize, add: Vec) { add_impl(self, index, remove, add, false); } + /// Create an edit: but insert `add` before existing additions. pub fn add_before(&mut self, index: usize, remove: usize, add: Vec) { add_impl(self, index, remove, add, true); } @@ -134,7 +135,7 @@ impl EditMap { } } -/// To do. +/// Create an edit. fn add_impl( edit_map: &mut EditMap, index: usize, @@ -145,9 +146,10 @@ fn add_impl( assert!(!edit_map.consumed, "cannot add after consuming"); if let Some((curr_remove, mut curr_add)) = edit_map.map.remove(&index) { - // To do: these might have to be split in several chunks instead + // To do: these might have to be split into several chunks instead // of one, if links in `curr_add` are supported. remove += curr_remove; + if before { add.append(&mut curr_add); } else { -- cgit