From 0ecc3bed75dac31222b17843e0c6a2cbecde81e6 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 9 Sep 2016 01:09:16 +0200 Subject: [PATCH] Fixed Source::SpellCheckView::is_code_iter for some languages --- src/source_spellcheck.cc | 22 +++++++++++++++++++--- src/source_spellcheck.h | 3 +++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/source_spellcheck.cc b/src/source_spellcheck.cc index 54c77b9..e095fcb 100644 --- a/src/source_spellcheck.cc +++ b/src/source_spellcheck.cc @@ -186,11 +186,21 @@ Source::SpellCheckView::SpellCheckView() : Gsv::View() { return false; }); - get_buffer()->get_tag_table()->signal_tag_added().connect([this](const Glib::RefPtr &tag) { + signal_tag_added_connection=get_buffer()->get_tag_table()->signal_tag_added().connect([this](const Glib::RefPtr &tag) { if(tag->property_name()=="gtksourceview:context-classes:comment") comment_tag=tag; else if(tag->property_name()=="gtksourceview:context-classes:string") string_tag=tag; + else if(tag->property_name()=="gtksourceview:context-classes:no-spell-check") + no_spell_check_tag=tag; + }); + signal_tag_removed_connection=get_buffer()->get_tag_table()->signal_tag_removed().connect([this](const Glib::RefPtr &tag) { + if(tag->property_name()=="gtksourceview:context-classes:comment") + comment_tag.reset(); + else if(tag->property_name()=="gtksourceview:context-classes:string") + string_tag.reset(); + else if(tag->property_name()=="gtksourceview:context-classes:no-spell-check") + no_spell_check_tag.reset(); }); } @@ -200,6 +210,9 @@ Source::SpellCheckView::~SpellCheckView() { if(spellcheck_checker!=nullptr) delete_aspell_speller(spellcheck_checker); + + signal_tag_added_connection.disconnect(); + signal_tag_removed_connection.disconnect(); } void Source::SpellCheckView::configure() { @@ -308,13 +321,16 @@ void Source::SpellCheckView::goto_next_spellcheck_error() { } bool Source::SpellCheckView::is_code_iter(const Gtk::TextIter &iter) { - if(spellcheck_all) - return false; if(*iter=='\'') { auto previous_iter=iter; if(!iter.starts_line() && previous_iter.backward_char() && *previous_iter=='\'') return false; } + if(spellcheck_all) { + if(no_spell_check_tag && (iter.has_tag(no_spell_check_tag) || iter.begins_tag(no_spell_check_tag) || iter.ends_tag(no_spell_check_tag))) + return true; + return false; + } if(comment_tag && ((iter.has_tag(comment_tag) && !iter.begins_tag(comment_tag)) || iter.ends_tag(comment_tag))) return false; if(string_tag && iter.has_tag(string_tag) && !iter.begins_tag(string_tag)) diff --git a/src/source_spellcheck.h b/src/source_spellcheck.h index 41d8826..ac9eb35 100644 --- a/src/source_spellcheck.h +++ b/src/source_spellcheck.h @@ -28,6 +28,9 @@ namespace Source { Glib::RefPtr comment_tag; Glib::RefPtr string_tag; + Glib::RefPtr no_spell_check_tag; + sigc::connection signal_tag_added_connection; + sigc::connection signal_tag_removed_connection; static AspellConfig* spellcheck_config; AspellCanHaveError *spellcheck_possible_err;