fix bug with adding multiple tags at once

This commit is contained in:
GenevensiS
2026-03-18 05:48:30 +01:00
parent 1210dcdf16
commit 87dbb2d7aa
3 changed files with 82 additions and 16 deletions
+13 -7
View File
@@ -119,14 +119,20 @@ unique_ptr<TextValueAction> toggle_format_action(const TextValueP& value, vector
tag == _("li") ? compute_new_bullet_value (new_value, offset, start_i, end_i):
compute_new_simple_value (new_value, tag, start_i, end_i);
// Erase redundant tags
if (start != end) {
// don't simplify if start == end, this way we insert <b></b>, allowing the
// user to press Ctrl+B and start typing bold text
new_value = simplify_tagged(new_value);
if (start != end) {
// Simplify
new_value = simplify_tagged(new_value);
// Adjust selection
start_i = to_tagged_pos(new_value, untagged_start_i, true, true, true);
end_i = to_tagged_pos(new_value, untagged_end_i, false, false, false);
}
else {
// Don't simplify if start == end, this way we insert <b></b>,
// allowing the user to press Ctrl+B and start typing bold text
// Adjust selection
start_i = to_tagged_pos(new_value, untagged_start_i, true, false, true);
end_i = to_tagged_pos(new_value, untagged_end_i, true, false, true);
}
// Adjust selection
start_i = to_tagged_pos(new_value, untagged_start_i, true, false);
end_i = to_tagged_pos(new_value, untagged_end_i, true, false);
}
// Build action
if (value->value() == new_value) {