simplification, stricter adherence to projectional editing approach

This commit is contained in:
Anton-4 2022-02-21 14:47:57 +01:00
parent 5374f6d6b8
commit 48d5775f62
No known key found for this signature in database
GPG key ID: C954D6E0F9C0ABFD
19 changed files with 274 additions and 364 deletions

View file

@ -468,3 +468,33 @@ pub fn join_mark_nodes_commas(
mark_nodes.into_iter().interleave(join_nodes).collect()
}
pub fn mark_nodes_to_string(
markup_node_ids: &[MarkNodeId],
mark_node_pool: &SlowPool,
) -> String {
let mut all_code_string = String::new();
for mark_node_id in markup_node_ids.iter() {
node_to_string_w_children(*mark_node_id, &mut all_code_string, mark_node_pool)
}
all_code_string
}
pub fn node_to_string_w_children(node_id: MarkNodeId, str_buffer: &mut String, mark_node_pool: &SlowPool) {
let node = mark_node_pool.get(node_id);
if node.is_nested() {
for child_id in node.get_children_ids() {
node_to_string_w_children(child_id, str_buffer, mark_node_pool);
}
for _ in 0..node.get_newlines_at_end() {
str_buffer.push('\n')
}
} else {
let node_content_str = node.get_full_content();
str_buffer.push_str(&node_content_str);
}
}