From 3647273e1989ba5ab02b8a705ba28ad99551c984 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 11 Feb 2018 10:45:33 +0100 Subject: [PATCH] Fixes spellcheck error fault when ending a string with ' --- src/source_spellcheck.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/source_spellcheck.cc b/src/source_spellcheck.cc index 895b80d..8db8f63 100644 --- a/src/source_spellcheck.cc +++ b/src/source_spellcheck.cc @@ -384,6 +384,20 @@ bool Source::SpellCheckView::is_code_iter(const Gtk::TextIter &iter) { } if(string_tag) { if(iter.has_tag(string_tag)) { + // When ending an open ''-string with ', the last '-iter is not correctly marked as end iter for string_tag + // For instance 'test, when inserting ' at end, would lead to spellcheck error of test' + if(*iter=='\'') { + long backslash_count=0; + auto it=iter; + while(it.backward_char() && *it=='\\') + ++backslash_count; + if(backslash_count%2==0) { + auto it=iter; + while(!it.begins_tag(string_tag) && it.backward_to_tag_toggle(string_tag)) {} + if(it.begins_tag(string_tag) && *it=='\'' && iter!=it) + return true; + } + } if(!iter.begins_tag(string_tag)) return false; }