From ce367695f2d66f839f2ec1cb707fb2378db06ab1 Mon Sep 17 00:00:00 2001 From: Gary Li Date: Sun, 9 Apr 2023 11:21:05 +0000 Subject: batch-rename-dialog: fix tag intersection for zero-length deletions Dead keys insert a provisional visual indication, which looks like a text insertion, but is actually signaled as `::delete-text`. Unlike regular emissions of `::delete-text`, here the start and end positions are exactly the same (so you know nothing is actually deleted). Nautilus deletes the neighbouring tag When a dead key is entered into the batch rename entry, it deletes the neighbouring tag. This occurs for just before, inside and just after the tag. This happens because our logic for knowing when to delete special text tags is assuming end_position > start_position, which is not the case with dead keys. Add conditions to ensure intersecting selections cannot be zero-length. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2821 --- src/nautilus-batch-rename-dialog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c index 682b7753d..a111c7b92 100644 --- a/src/nautilus-batch-rename-dialog.c +++ b/src/nautilus-batch-rename-dialog.c @@ -1584,9 +1584,11 @@ get_tags_intersecting_sorted (NautilusBatchRenameDialog *self, if (text_changed_mode == TEXT_WAS_DELETED) { selection_intersects_tag_start = end_position > tag_data->position && - end_position <= tag_end_position; + end_position <= tag_end_position && + start_position <= tag_data->position; selection_intersects_tag_end = start_position >= tag_data->position && - start_position < tag_end_position; + start_position < tag_end_position && + end_position >= tag_end_position; tag_is_contained_in_selection = start_position <= tag_data->position && end_position >= tag_end_position; } -- cgit v1.2.1