Synchronize spelling panel and buffer languages

If the spelling panel is visible when checkSpelling: is invoked then its language is taken and used for the buffer. If the panel is not visible, the buffer’s language is set for the spelling panel.

We probably should also set the spelling panel’s language when switching document, and when the panel is first opened. I don’t think the code complexity is really worth it though (depends on how often one use the spelling panel with a non-default language).

Fixes #1104
This commit is contained in:
Allan Odgaard
2013-09-04 12:39:06 +02:00
parent d265d24441
commit 68bf3efff9

View File

@@ -2431,6 +2431,20 @@ static char const* kOakMenuItemTitle = "OakMenuItemTitle";
NSSpellChecker* speller = [NSSpellChecker sharedSpellChecker];
ng::buffer_t& buf = document->buffer();
NSString* lang = [NSString stringWithCxxString:buf.spelling_language()];
if([[speller spellingPanel] isVisible])
{
if(![[speller language] isEqualToString:lang])
{
buf.set_spelling_language(to_s([speller language]));
[self setNeedsDisplay:YES];
}
}
else
{
[speller setLanguage:lang];
}
if(!buf.live_spelling())
{
buf.set_live_spelling(true);