mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix incorrect results when running replace all on marked text and more than one replacement is made. Fixes #1348941 [When applying the command Replace all with marked text, error happens](https://bugs.launchpad.net/calibre/+bug/1348941)
This commit is contained in:
parent
3eb87c29f9
commit
5881287671
@ -348,9 +348,10 @@ class TextEdit(PlainTextEdit):
|
||||
else:
|
||||
raw, count = pat.subn(template, raw)
|
||||
if count > 0:
|
||||
c.setKeepPositionOnInsert(True)
|
||||
start_pos = min(c.anchor(), c.position())
|
||||
c.insertText(raw)
|
||||
c.setKeepPositionOnInsert(False)
|
||||
end_pos = max(c.anchor(), c.position())
|
||||
c.setPosition(start_pos), c.setPosition(end_pos, c.KeepAnchor)
|
||||
self.update_extra_selections()
|
||||
return count
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user