mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 22:04:55 +02:00
Improve smart highlighting performance
Abort highlight search if the selection crosses a line boundry. Closes #3908
This commit is contained in:
parent
f07ebbf806
commit
999b1cfa7b
@ -127,6 +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;
|
||||||
|
|
||||||
// Determine mode for SmartHighlighting
|
// Determine mode for SmartHighlighting
|
||||||
bool isWordOnly = true;
|
bool isWordOnly = true;
|
||||||
@ -153,8 +154,14 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
|
|||||||
if (wordStart == wordEnd || wordStart != range.cpMin || wordEnd != range.cpMax)
|
if (wordStart == wordEnd || wordStart != range.cpMin || wordEnd != range.cpMax)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
int textlen = range.cpMax - range.cpMin + 1;
|
{
|
||||||
|
auto line = pHighlightView->execute(SCI_LINEFROMPOSITION, curPos);
|
||||||
|
auto lineLength = pHighlightView->execute(SCI_LINELENGTH, line);
|
||||||
|
if (textlen > lineLength)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char * text2Find = new char[textlen];
|
char * text2Find = new char[textlen];
|
||||||
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false)
|
pHighlightView->getSelectedText(text2Find, textlen, false); //do not expand selection (false)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user