diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 182afff13..d05188641 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2688,7 +2688,36 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (nppGui._enableTagsMatchHilite) { XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView); - xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite); + pair tagPos = xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite); + + int braceAtCaret = tagPos.first; + int braceOpposite = tagPos.second; + + if ((braceAtCaret != -1) && (braceOpposite == -1)) + { + _pEditView->execute(SCI_SETHIGHLIGHTGUIDE, 0); + } + else if (_pEditView->isShownIndentGuide()) + { + int columnAtCaret = int(_pEditView->execute(SCI_GETCOLUMN, braceAtCaret)); + int columnOpposite = int(_pEditView->execute(SCI_GETCOLUMN, braceOpposite)); + + int lineAtCaret = int(_pEditView->execute(SCI_LINEFROMPOSITION, braceAtCaret)); + int lineOpposite = int(_pEditView->execute(SCI_LINEFROMPOSITION, braceOpposite)); + if (lineAtCaret != lineOpposite) + { + StyleArray & stylers = nppParam->getMiscStylerArray(); + int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_TAGMATCH); + if (iFind) + { + Style *pStyle = &(stylers.getStyler(iFind)); + _pEditView->execute(SCI_STYLESETFORE, STYLE_BRACELIGHT, pStyle->_bgColor); + } + // braceAtCaret - 1, braceOpposite-1 : walk around to not highlight the '<' + _pEditView->execute(SCI_BRACEHIGHLIGHT, braceAtCaret-1, braceOpposite-1); + _pEditView->execute(SCI_SETHIGHLIGHTGUIDE, (columnAtCaret < columnOpposite)?columnAtCaret:columnOpposite); + } + } } if (nppGui._enableSmartHilite) @@ -3090,7 +3119,7 @@ void Notepad_plus::braceMatch() if ((braceAtCaret != -1) && (braceOpposite == -1)) { _pEditView->execute(SCI_BRACEBADLIGHT, braceAtCaret); - _pEditView->execute(SCI_SETHIGHLIGHTGUIDE); + _pEditView->execute(SCI_SETHIGHLIGHTGUIDE, 0); } else { diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp index 844fd7228..be6252900 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp @@ -439,7 +439,7 @@ vector< pair > XmlMatchedTagsHighlighter::getAttributesPos(int start, -void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) +pair XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) { // Clean up all marks of previous action _pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH); @@ -449,7 +449,7 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) LangType lang = (_pEditView->getCurrentBuffer())->getLangType(); if (lang != L_XML && lang != L_HTML && lang != L_PHP && lang != L_ASP) - return; + return pair(-1, -1); // Get the original targets and search options to restore after tag matching operation int originalStartPos = _pEditView->execute(SCI_GETTARGETSTART); @@ -490,4 +490,6 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) _pEditView->execute(SCI_SETTARGETSTART, originalStartPos); _pEditView->execute(SCI_SETTARGETEND, originalEndPos); _pEditView->execute(SCI_SETSEARCHFLAGS, originalSearchFlags); + + return pair(xmlTags.tagOpenStart, xmlTags.tagCloseStart); } diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h index b0b40b9fb..6c3f99605 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h @@ -27,7 +27,7 @@ enum TagCateg {tagOpen, tagClose, inSingleTag, outOfTag, invalidTag, unknownPb}; class XmlMatchedTagsHighlighter { public: XmlMatchedTagsHighlighter(ScintillaEditView *pEditView):_pEditView(pEditView){}; - void tagMatch(bool doHiliteAttr); + pair tagMatch(bool doHiliteAttr); private: struct XmlMatchedTagsPos {