From 68bf3efff9d22729fe70fcb2d9c5224fd2dcf3e7 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Wed, 4 Sep 2013 12:39:06 +0200 Subject: [PATCH] Synchronize spelling panel and buffer languages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Frameworks/OakTextView/src/OakTextView.mm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Frameworks/OakTextView/src/OakTextView.mm b/Frameworks/OakTextView/src/OakTextView.mm index 441ac21e..f34ca5ad 100644 --- a/Frameworks/OakTextView/src/OakTextView.mm +++ b/Frameworks/OakTextView/src/OakTextView.mm @@ -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);