Fix regression of URL double click issue

Fix #9320
This commit is contained in:
Don HO 2020-12-31 03:38:16 +01:00
parent 413762c393
commit 9c8497a99d
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
3 changed files with 24 additions and 16 deletions

View File

@ -820,8 +820,13 @@ BOOL Notepad_plus::notify(SCNotification *notification)
else
{ // Double click with no modifiers
// Check wether cursor is within URL
int startPos = 0, endPos = 0;
if (!notifyView->getIndicatorRange(URL_INDIC, &startPos, &endPos))
auto indicMsk = notifyView->execute(SCI_INDICATORALLONFOR, notification->position);
if (!(indicMsk & (1 << URL_INDIC)))
break;
auto startPos = notifyView->execute(SCI_INDICATORSTART, URL_INDIC, notification->position);
auto endPos = notifyView->execute(SCI_INDICATOREND, URL_INDIC, notification->position);
if ((notification->position < startPos) || (notification->position > endPos))
break;
// WM_LBUTTONUP goes to opening browser instead of Scintilla here, because the mouse is not captured.

View File

@ -3327,6 +3327,22 @@ void ScintillaEditView::foldChanged(size_t line, int levelNow, int levelPrev)
}
}
bool ScintillaEditView::getIndicatorRange(int indicatorNumber, int *from, int *to, int *cur)
{
int curPos = static_cast<int>(execute(SCI_GETCURRENTPOS));
int indicMsk = static_cast<int>(execute(SCI_INDICATORALLONFOR, curPos));
if (!(indicMsk & (1 << indicatorNumber)))
return false;
int startPos = static_cast<int>(execute(SCI_INDICATORSTART, indicatorNumber, curPos));
int endPos = static_cast<int>(execute(SCI_INDICATOREND, indicatorNumber, curPos));
if ((curPos < startPos) || (curPos > endPos))
return false;
if (from) *from = startPos;
if (to) *to = endPos;
if (cur) *cur = curPos;
return true;
};
void ScintillaEditView::scrollPosToCenter(size_t pos)
{

View File

@ -559,20 +559,7 @@ public:
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd-docStart);
};
bool getIndicatorRange(int indicatorNumber, int *from = NULL, int *to = NULL, int *cur = NULL) {
int curPos = static_cast<int>(execute(SCI_GETCURRENTPOS));
int indicMsk = static_cast<int>(execute(SCI_INDICATORALLONFOR, curPos));
if (!(indicMsk & (1 << indicatorNumber)))
return false;
int startPos = static_cast<int>(execute(SCI_INDICATORSTART, indicatorNumber, curPos));
int endPos = static_cast<int>(execute(SCI_INDICATOREND, indicatorNumber, curPos));
if ((curPos < startPos) || (curPos > endPos))
return false;
if (from) *from = startPos;
if (to) *to = endPos;
if (cur) *cur = curPos;
return true;
};
bool getIndicatorRange(int indicatorNumber, int *from = NULL, int *to = NULL, int *cur = NULL);
static LanguageName langNames[L_EXTERNAL+1];