From a633f1611e87c86f8b6b811872c7cac086c24063 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 2 Sep 2015 10:46:13 +0200 Subject: [PATCH] Fixes: spellcheck when using backspace, diagnostics underlines, and tooltips area of activation. --- src/source.cc | 11 ++++++++--- src/source.h | 1 + src/tooltips.cc | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/source.cc b/src/source.cc index 62ff411..f633935 100644 --- a/src/source.cc +++ b/src/source.cc @@ -186,10 +186,11 @@ Source::View::View(const boost::filesystem::path &file_path): file_path(file_pat delayed_spellcheck_suggestions_connection.disconnect(); auto iter=get_buffer()->get_insert()->get_iter(); - if(iter.backward_char()) { + if(last_keyval_is_backspace || iter.backward_char()) { auto context_iter=iter; if(context_iter.backward_char()) { if((spellcheck_all && !get_source_buffer()->iter_has_context_class(context_iter, "no-spell-check")) || get_source_buffer()->iter_has_context_class(context_iter, "comment") || get_source_buffer()->iter_has_context_class(context_iter, "string")) { + cout << (char)*iter << endl; if(*iter==32 || *iter==45) { //Might have used space or - to split two words auto first=iter; auto second=iter; @@ -510,6 +511,10 @@ bool Source::View::on_key_press_event(GdkEventKey* key) { if(spellcheck_suggestions_dialog->on_key_press(key)) return true; } + if(key->keyval==GDK_KEY_BackSpace) + last_keyval_is_backspace=true; + else + last_keyval_is_backspace=false; get_source_buffer()->begin_user_action(); //Indent as in next or previous line @@ -1013,11 +1018,11 @@ void Source::ClangViewParse::update_diagnostics() { if(diagnostic.path==file_path.string()) { auto start_line=get_line(diagnostic.offsets.first.line-1); //index is sometimes off the line auto start_line_index=diagnostic.offsets.first.index-1; - if(start_line_index>=start_line.size()) { + if(start_line_index>start_line.size()) { if(start_line.size()==0) start_line_index=0; else - start_line_index=start_line.size()-1; + start_line_index=start_line.size(); } auto end_line=get_line(diagnostic.offsets.second.line-1); //index is sometimes off the line auto end_line_index=diagnostic.offsets.second.index-1; diff --git a/src/source.h b/src/source.h index c89b365..6480d6b 100644 --- a/src/source.h +++ b/src/source.h @@ -114,6 +114,7 @@ namespace Source { std::unique_ptr spellcheck_suggestions_dialog; bool spellcheck_suggestions_dialog_shown=false; sigc::connection delayed_spellcheck_suggestions_connection; + bool last_keyval_is_backspace=false; }; class GenericView : public View { diff --git a/src/tooltips.cc b/src/tooltips.cc index 9ac2fb5..113ce64 100644 --- a/src/tooltips.cc +++ b/src/tooltips.cc @@ -35,7 +35,7 @@ void Tooltip::update() { auto end_iter=end_mark->get_iter(); text_view.get_iter_location(iter, activation_rectangle); if(iter.get_offset()