mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression that sometimes caused incorrect syntax highlighting when non-breaking spaces/typographic hyphens are present in the text. Fixes #1321317 [Edit book: Wrong hilighting in spaces](https://bugs.launchpad.net/calibre/+bug/1321317)
This commit is contained in:
parent
69ab170c19
commit
45436c4450
@ -238,6 +238,8 @@ def process_text(state, text, nbsp_format, spell_format, user_data):
|
|||||||
last = m.end()
|
last = m.end()
|
||||||
if not ans:
|
if not ans:
|
||||||
ans = [(len(text), fmt)]
|
ans = [(len(text), fmt)]
|
||||||
|
elif last < len(text):
|
||||||
|
ans.append((len(text) - last, fmt))
|
||||||
|
|
||||||
if tprefs['inline_spell_check'] and state.tags and user_data.tag_ok_for_spell(state.tags[-1].name) and hasattr(dictionaries, 'active_user_dictionaries'):
|
if tprefs['inline_spell_check'] and state.tags and user_data.tag_ok_for_spell(state.tags[-1].name) and hasattr(dictionaries, 'active_user_dictionaries'):
|
||||||
split_ans = []
|
split_ans = []
|
||||||
@ -262,8 +264,8 @@ def process_text(state, text, nbsp_format, spell_format, user_data):
|
|||||||
wsfmt = SyntaxTextCharFormat(sfmt)
|
wsfmt = SyntaxTextCharFormat(sfmt)
|
||||||
wsfmt.setProperty(SPELL_PROPERTY, (ctext[start:ppos], locale))
|
wsfmt.setProperty(SPELL_PROPERTY, (ctext[start:ppos], locale))
|
||||||
split_ans.append((length, fmt if recognized else wsfmt))
|
split_ans.append((length, fmt if recognized else wsfmt))
|
||||||
if ppos == 0:
|
if ppos < tlen:
|
||||||
split_ans.append((tlen, fmt))
|
split_ans.append((tlen - ppos, fmt))
|
||||||
|
|
||||||
tpos += tlen
|
tpos += tlen
|
||||||
ans = split_ans
|
ans = split_ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user