Fix smart-highlighting not applying to cloned view

Fixed smart-highlighting not applying to cloned view while "Highlight another view" is enabled.

Fix #7910, close #8905
This commit is contained in:
jofon 2020-09-26 16:35:23 +01:00 committed by Don HO
parent c94f84000b
commit 139e4d4925
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 10 additions and 7 deletions

View File

@ -862,8 +862,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (notification->nmhdr.hwndFrom != _pEditView->getHSelf()) // notification come from unfocus view - both views ae visible if (notification->nmhdr.hwndFrom != _pEditView->getHSelf()) // notification come from unfocus view - both views ae visible
{ {
//ScintillaEditView * unfocusView = isFromPrimary ? &_subEditView : &_mainEditView; //ScintillaEditView * unfocusView = isFromPrimary ? &_subEditView : &_mainEditView;
if (nppGui._smartHiliteOnAnotherView && if (nppGui._smartHiliteOnAnotherView)
_pEditView->getCurrentBufferID() != notifyView->getCurrentBufferID())
{ {
TCHAR selectedText[1024]; TCHAR selectedText[1024];
_pEditView->getGenericSelectedText(selectedText, sizeof(selectedText)/sizeof(TCHAR), false); _pEditView->getGenericSelectedText(selectedText, sizeof(selectedText)/sizeof(TCHAR), false);

View File

@ -171,11 +171,15 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
highlightViewWithWord(pHighlightView, text2FindW); highlightViewWithWord(pHighlightView, text2FindW);
if (nppGUI._smartHiliteOnAnotherView && unfocusView && unfocusView->isVisible() if (nppGUI._smartHiliteOnAnotherView && unfocusView && unfocusView->isVisible())
&& unfocusView->getCurrentBufferID() != pHighlightView->getCurrentBufferID()) {
// Clear the indicator only when the view is not a clone, or it will clear what we have already hightlighted in the pHighlightView
if (unfocusView->getCurrentBufferID() != pHighlightView->getCurrentBufferID())
{ {
// Clear marks
unfocusView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART); unfocusView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
}
// Hightlight the unfocused view even if it's a clone, as it might be in a different area of the document
highlightViewWithWord(unfocusView, text2FindW); highlightViewWithWord(unfocusView, text2FindW);
} }