aboutsummaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-05 13:31:46 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-05 13:31:46 +0200
commitf2d62d446a7b1e03ef14b580e2aca0fad8aa23ef (patch)
treeb2a837d99cb0e4a4de0bfd82051e10a2db8c6456 /src/util
parentfd860a975b84da9a79abfa247787e6adbd5ea34c (diff)
downloadmarkdown-rs-f2d62d446a7b1e03ef14b580e2aca0fad8aa23ef.tar.gz
markdown-rs-f2d62d446a7b1e03ef14b580e2aca0fad8aa23ef.tar.bz2
markdown-rs-f2d62d446a7b1e03ef14b580e2aca0fad8aa23ef.zip
Refactor to do some to dos
Diffstat (limited to '')
-rw-r--r--src/util/edit_map.rs6
1 files changed, 4 insertions, 2 deletions
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<Event>) {
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<Event>) {
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 {