From 62f7d3f97c3fdd7ff84bfc222f54f1106137df1f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Jan 2015 13:11:07 +0530 Subject: [PATCH] Fix position update for placeholders when removing characters --- src/calibre/gui2/tweak_book/editor/snippets.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/snippets.py b/src/calibre/gui2/tweak_book/editor/snippets.py index 037b60020b..0a31944c3c 100644 --- a/src/calibre/gui2/tweak_book/editor/snippets.py +++ b/src/calibre/gui2/tweak_book/editor/snippets.py @@ -33,7 +33,7 @@ def snip_key(trigger, *syntaxes): def contains(l1, r1, l2, r2): # True iff (l2, r2) if contained in (l1, r1) - return l2 >= l1 and r2 <= r1 + return l2 > l1 and r2 < r1 builtin_snippets = { # {{{ snip_key('Lorem', 'html', 'xml'): { @@ -247,9 +247,9 @@ class EditorTabStop(object): self.is_deleted = True return if position <= self.left: - self.left -= chars_removed + self.left = max(self.left - chars_removed, position) if position <= self.right: - self.right -= chars_removed + self.right = max(self.right - chars_removed, position) if chars_added > 0: if position < self.left: @@ -459,7 +459,6 @@ class EditSnippet(QWidget): d.snippet_manager.snip_func = self.snip_func d.setToolTip(_('You can test your snippet here')) d.setMaximumHeight(t.maximumHeight() + 15) - d.setToolTip add_row(_('T&est:'), d) i = QListWidgetItem(_('All'), t)