Fix #2034900 [Editor - Report: UnboundLocalError: local variable 'raw' referenced before assignment](https://bugs.launchpad.net/calibre/+bug/2034900)

This commit is contained in:
Kovid Goyal 2023-09-08 14:41:42 +05:30
parent 3f217c9cb9
commit 0d4b57722a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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