From f7d8b9c9e9e3f97efc5f9ea87f2830813d3a285f Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 3 Oct 2015 11:45:48 +0200 Subject: [PATCH] Improved spellcheck context settings for non-clang files. --- src/source.cc | 15 ++++++++++++--- src/source.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/source.cc b/src/source.cc index 4536f16..c9ef005 100644 --- a/src/source.cc +++ b/src/source.cc @@ -1210,13 +1210,16 @@ Source::GenericView::GenericView(const boost::filesystem::path &file_path, Glib: catch(const std::exception &e) { Singleton::terminal()->print("Error: error parsing language file "+language_file.string()+": "+e.what()+'\n'); } - add_keywords(completion_buffer_keywords, pt); + bool has_context_class=false; + parse_language_file(completion_buffer_keywords, has_context_class, pt); + if(!has_context_class) + spellcheck_all=false; completion_words->register_provider(completion_buffer_keywords); } } } -void Source::GenericView::add_keywords(Glib::RefPtr &completion_buffer, const boost::property_tree::ptree &pt) { +void Source::GenericView::parse_language_file(Glib::RefPtr &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt) { bool case_insensitive=false; for(auto &node: pt) { if(node.first=="") { @@ -1231,8 +1234,14 @@ void Source::GenericView::add_keywords(Glib::RefPtr &completio completion_buffer->insert_at_cursor(data+'\n'); } } + else if(!has_context_class && node.first=="context") { + auto class_attribute=node.second.get(".class", ""); + auto class_disabled_attribute=node.second.get(".class-disabled", ""); + if(class_attribute.size()>0 || class_disabled_attribute.size()>0) + has_context_class=true; + } try { - add_keywords(completion_buffer, node.second); + parse_language_file(completion_buffer, has_context_class, node.second); } catch(const std::exception &e) { } diff --git a/src/source.h b/src/source.h index 4cb7ece..c69f178 100644 --- a/src/source.h +++ b/src/source.h @@ -171,7 +171,7 @@ namespace Source { public: GenericView(const boost::filesystem::path &file_path, Glib::RefPtr language); - void add_keywords(Glib::RefPtr &completion_buffer, const boost::property_tree::ptree &pt); + void parse_language_file(Glib::RefPtr &completion_buffer, bool &has_context_class, const boost::property_tree::ptree &pt); }; class ClangViewParse : public View {