From 6f6bd4b32fa44745a66dc511e7c753fa375a14a6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 22 Sep 2023 13:33:55 +0530 Subject: [PATCH] Edit book: Fix smart tag insert not working correctly if the selected text starts with the closing angle bracket of a tag --- src/calibre/gui2/tweak_book/editor/smarts/html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/editor/smarts/html.py b/src/calibre/gui2/tweak_book/editor/smarts/html.py index 310bfd2ee7..7ac01e57bd 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/html.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/html.py @@ -275,7 +275,7 @@ def ensure_not_within_tag_definition(cursor, forward=True): if boundary.is_start: # We are inside a tag if forward: - block, boundary = next_tag_boundary(block, offset) + block, boundary = next_tag_boundary(block, max(0, offset-1)) if block is not None: cursor.setPosition(block.position() + boundary.offset + 1) return True