Fix bug with smart highlight of data and end-of-file

Fix #8908, close #8911
This commit is contained in:
Scott Sumner 2020-09-27 09:01:31 -04:00 committed by Don HO
parent 9ab554a129
commit a08784fa43
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -127,7 +127,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
auto curPos = pHighlightView->execute(SCI_GETCURRENTPOS); auto curPos = pHighlightView->execute(SCI_GETCURRENTPOS);
auto range = pHighlightView->getSelection(); auto range = pHighlightView->getSelection();
int textlen = range.cpMax - range.cpMin + 1; int textlen = range.cpMax - range.cpMin;
// Determine mode for SmartHighlighting // Determine mode for SmartHighlighting
bool isWordOnly = true; bool isWordOnly = true;
@ -162,8 +162,8 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
return; return;
} }
char * text2Find = new char[textlen]; char * text2Find = new char[textlen + 1];
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false) pHighlightView->getSelectedText(text2Find, textlen + 1, false); //do not expand selection (false)
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
UINT cp = static_cast<UINT>(pHighlightView->execute(SCI_GETCODEPAGE)); UINT cp = static_cast<UINT>(pHighlightView->execute(SCI_GETCODEPAGE));