Sonnet: fix wrong language for suggestions in mixed-language texts

Authored by dfaure on Mar 26 2017, 9:06 AM.

Description

Sonnet: fix wrong language for suggestions in mixed-language texts

When AutoDetectLanguage is set, the same document can contain multiple
languages. In that case, Highlighter stores the language information
into the block's userdata, and changes the spellchecker language at
every change. So the suggestions were using whatever was the language
of the last block that was checked, which led to pretty random behaviour
for the user.

Fixed by using a QTextCursor to retrieve the cached language for the
word we're showing suggestions for.

Test Plan:
Spellchecking in kmail composer, writing text in French
and having a signature with word in English.

Reviewers: sandsmark, mlaurent

Subscribers: KDE PIM, Frameworks

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D9491