This commit is contained in:
Kovid Goyal 2014-06-23 21:29:21 +05:30
parent 61113c887a
commit 9e8d51359f

View File

@ -239,17 +239,17 @@ def cdata(state, text, i, formats, user_data):
def check_spelling(text, tpos, tlen, fmt, locale, sfmt): def check_spelling(text, tpos, tlen, fmt, locale, sfmt):
split_ans = [] split_ans = []
ctext = text[tpos:tpos+tlen]
ppos = 0 ppos = 0
for start, length in split_into_words_and_positions(ctext, lang=locale.langcode): sl = store_locale.enabled
for start, length in split_into_words_and_positions(text[tpos:tpos+tlen], lang=locale.langcode):
if start > ppos: if start > ppos:
split_ans.append((start - ppos, fmt)) split_ans.append((start - ppos, fmt))
ppos = start + length ppos = start + length
recognized = dictionaries.recognized(ctext[start:ppos], locale) recognized = dictionaries.recognized(text[tpos + start:ppos], locale)
if recognized: if recognized:
split_ans.append((length, fmt)) split_ans.append((length, fmt))
else: else:
if store_locale.enabled: if sl:
s = QTextCharFormat(sfmt) s = QTextCharFormat(sfmt)
s.setProperty(SPELL_LOCALE_PROPERTY, locale) s.setProperty(SPELL_LOCALE_PROPERTY, locale)
split_ans.append((length, s)) split_ans.append((length, s))