mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Text search: Fix searching for a single character backwards not working
This commit is contained in:
parent
36604c52ee
commit
64141ab21f
@ -733,12 +733,14 @@ class Smarts(NullSmarts):
|
|||||||
|
|
||||||
return 'complete_names', (names_type, doc_name, c.root), query
|
return 'complete_names', (names_type, doc_name, c.root), query
|
||||||
|
|
||||||
def find_text(self, pat, cursor):
|
def find_text(self, pat, cursor, reverse):
|
||||||
from calibre.gui2.tweak_book.text_search import find_text_in_chunks
|
from calibre.gui2.tweak_book.text_search import find_text_in_chunks
|
||||||
chunks = []
|
chunks = []
|
||||||
|
|
||||||
cstart = min(cursor.position(), cursor.anchor())
|
cstart = min(cursor.position(), cursor.anchor())
|
||||||
cend = max(cursor.position(), cursor.anchor())
|
cend = max(cursor.position(), cursor.anchor())
|
||||||
|
if reverse:
|
||||||
|
cend -= 1
|
||||||
c = QTextCursor(cursor)
|
c = QTextCursor(cursor)
|
||||||
c.setPosition(cstart)
|
c.setPosition(cstart)
|
||||||
block = c.block()
|
block = c.block()
|
||||||
|
@ -503,7 +503,7 @@ class TextEdit(PlainTextEdit):
|
|||||||
c.movePosition(pos, c.KeepAnchor)
|
c.movePosition(pos, c.KeepAnchor)
|
||||||
if hasattr(self.smarts, 'find_text'):
|
if hasattr(self.smarts, 'find_text'):
|
||||||
self.highlighter.join()
|
self.highlighter.join()
|
||||||
found, start, end = self.smarts.find_text(pat, c)
|
found, start, end = self.smarts.find_text(pat, c, reverse)
|
||||||
if not found:
|
if not found:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user