diff --git a/common/scintilla_tricks.cpp b/common/scintilla_tricks.cpp index 3e5bb76559..f1ffb3250d 100644 --- a/common/scintilla_tricks.cpp +++ b/common/scintilla_tricks.cpp @@ -37,6 +37,8 @@ SCINTILLA_TRICKS::SCINTILLA_TRICKS( wxStyledTextCtrl* aScintilla, const wxString m_te( aScintilla ), m_braces( aBraces ), m_lastCaretPos( -1 ), + m_lastSelStart( -1 ), + m_lastSelEnd( -1 ), m_suppressAutocomplete( false ), m_singleLine( aSingleLine ), m_returnCallback( aReturnCallback ) @@ -337,10 +339,14 @@ void SCINTILLA_TRICKS::onScintillaUpdateUI( wxStyledTextEvent& aEvent ) // Has the caret changed position? int caretPos = m_te->GetCurrentPos(); + int selStart = m_te->GetSelectionStart(); + int selEnd = m_te->GetSelectionEnd(); - if( m_lastCaretPos != caretPos ) + if( m_lastCaretPos != caretPos || m_lastSelStart != selStart || m_lastSelEnd != selEnd ) { m_lastCaretPos = caretPos; + m_lastSelStart = selStart; + m_lastSelEnd = selEnd; int bracePos1 = -1; int bracePos2 = -1; diff --git a/include/scintilla_tricks.h b/include/scintilla_tricks.h index d06b19b7fb..dfc83fc09a 100644 --- a/include/scintilla_tricks.h +++ b/include/scintilla_tricks.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -56,6 +56,8 @@ protected: wxStyledTextCtrl* m_te; wxString m_braces; int m_lastCaretPos; + int m_lastSelStart; + int m_lastSelEnd; bool m_suppressAutocomplete; bool m_singleLine; // Treat as OK, and skip special tab // stop handling (including monospaced font).