mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Edit book: Fix a regression in the previous release that caused Text search to sometimes not select matches correctly. Fixes #2034900 [Editor - Report: UnboundLocalError: local variable 'raw' referenced before assignment](https://bugs.launchpad.net/calibre/+bug/2034900)
This commit is contained in:
parent
ff3af3ac15
commit
8c3ff7e7aa
@ -503,13 +503,13 @@ class TextEdit(PlainTextEdit):
|
||||
if wrap and not complete:
|
||||
pos = QTextCursor.MoveOperation.End if reverse else QTextCursor.MoveOperation.Start
|
||||
c.movePosition(pos, QTextCursor.MoveMode.KeepAnchor)
|
||||
raw = str(c.selectedText()).replace(PARAGRAPH_SEPARATOR, '\n').rstrip('\0')
|
||||
if hasattr(self.smarts, 'find_text'):
|
||||
self.highlighter.join()
|
||||
found, start, end = self.smarts.find_text(pat, c, reverse)
|
||||
if not found:
|
||||
return False
|
||||
else:
|
||||
raw = str(c.selectedText()).replace(PARAGRAPH_SEPARATOR, '\n').rstrip('\0')
|
||||
m = pat.search(raw)
|
||||
if m is None:
|
||||
return False
|
||||
|
@ -17,6 +17,7 @@ from calibre.gui2.tweak_book.search import (
|
||||
from calibre.gui2.widgets import BusyCursor
|
||||
from calibre.gui2.widgets2 import HistoryComboBox
|
||||
from calibre.startup import connect_lambda
|
||||
from calibre.utils.icu import utf16_length
|
||||
from polyglot.builtins import error_message, iteritems
|
||||
|
||||
# UI {{{
|
||||
@ -219,7 +220,7 @@ def find_text_in_chunks(pat, chunks):
|
||||
start_pos = chunk_start + (start - offset)
|
||||
if start_pos is not None:
|
||||
if contains(clen, after-1):
|
||||
end_pos = chunk_start + (after - offset)
|
||||
end_pos = chunk_start + utf16_length(chunk[:after-offset])
|
||||
return start_pos, end_pos
|
||||
offset += clen
|
||||
if offset > after:
|
||||
|
Loading…
x
Reference in New Issue
Block a user