From 39505b9d55f0cd5dcd8b1878d83941ab196b2ea9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Feb 2024 14:36:21 +0530 Subject: [PATCH] Fix #2051207 [Editor: Insert Link produces two undo actions](https://bugs.launchpad.net/calibre/+bug/2051207) --- src/calibre/gui2/tweak_book/editor/smarts/html.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calibre/gui2/tweak_book/editor/smarts/html.py b/src/calibre/gui2/tweak_book/editor/smarts/html.py index 7ac01e57bd..7c897cc832 100644 --- a/src/calibre/gui2/tweak_book/editor/smarts/html.py +++ b/src/calibre/gui2/tweak_book/editor/smarts/html.py @@ -480,6 +480,7 @@ class Smarts(NullSmarts): template = template.replace('_TEXT_', text or '') editor.highlighter.join() c = editor.textCursor() + c.beginEditBlock() if c.hasSelection(): c.insertText('') # delete any existing selected text ensure_not_within_tag_definition(c) @@ -487,6 +488,7 @@ class Smarts(NullSmarts): c.insertText(template) c.setPosition(p) # ensure cursor is positioned inside the newly created tag editor.setTextCursor(c) + c.endEditBlock() def insert_tag(self, editor, name): m = re.match(r'[a-zA-Z0-9:-]+', name)