Edit Book: Fix spelling correction suggestions not being shown when using the context menu key with the cursor at the end of the word

This commit is contained in:
Kovid Goyal 2016-02-28 15:28:46 +05:30
parent d155c08642
commit 316201354c

View File

@ -563,7 +563,7 @@ class TextEdit(PlainTextEdit):
formats = self.highlighter.parse_single_block(c.block())[0] formats = self.highlighter.parse_single_block(c.block())[0]
pos = c.positionInBlock() pos = c.positionInBlock()
for r in formats: for r in formats:
if r.start <= pos < r.start + r.length and r.format.property(SPELL_PROPERTY): if r.start <= pos <= r.start + r.length and r.format.property(SPELL_PROPERTY):
return r.format.property(SPELL_LOCALE_PROPERTY) return r.format.property(SPELL_LOCALE_PROPERTY)
def recheck_word(self, word, locale): def recheck_word(self, word, locale):
@ -583,7 +583,7 @@ class TextEdit(PlainTextEdit):
return return
pos = cursor.positionInBlock() pos = cursor.positionInBlock()
for r in cursor.block().layout().additionalFormats(): for r in cursor.block().layout().additionalFormats():
if r.start <= pos < r.start + r.length and r.format.property(SYNTAX_PROPERTY): if r.start <= pos <= r.start + r.length and r.format.property(SYNTAX_PROPERTY):
return r return r
def syntax_format_for_cursor(self, cursor): def syntax_format_for_cursor(self, cursor):