Skip to content

Commit

Permalink
Edit book: Fix searching for non-BMP unicode characters highlighting …
Browse files Browse the repository at this point in the history
…only half the character
  • Loading branch information
kovidgoyal committed Aug 22, 2023
1 parent 181dc06 commit 745dc0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/calibre/gui2/tweak_book/editor/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from calibre.gui2.tweak_book.widgets import PARAGRAPH_SEPARATOR, PlainTextEdit
from calibre.spell.break_iterator import index_of
from calibre.utils.icu import (
capitalize, lower, safe_chr, string_length, swapcase, upper
capitalize, lower, safe_chr, string_length, swapcase, upper, utf16_length
)
from calibre.utils.img import image_to_data
from calibre.utils.titlecase import titlecase
Expand Down Expand Up @@ -470,6 +470,7 @@ def find(self, pat, wrap=False, marked=False, complete=False, save_match=None):
start, end = m.span()
if start == end:
return False
end = start + utf16_length(raw[start:end])
if wrap and not complete:
if reverse:
textpos = c.anchor()
Expand Down Expand Up @@ -515,6 +516,7 @@ def find_text(self, pat, wrap=False, complete=False):
start, end = m.span()
if start == end:
return False
end = start + utf16_length(raw[start:end])
if reverse:
start, end = end, start
c.clearSelection()
Expand Down

0 comments on commit 745dc0c

Please sign in to comment.