[BUG_FIXED] (Author: Andreas Jonsson) Fix the crash issue while user Ctrl + double click on an empty document.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1342 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2015-02-13 23:30:34 +00:00
parent d5f8a23a09
commit deb3b8fcfe
1 changed files with 8 additions and 8 deletions

View File

@ -486,7 +486,14 @@ BOOL Notepad_plus::notify(SCNotification *notification)
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
std::string bufstring;
unsigned int position_of_click;
// For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1.
// In that case we use SCI_GETCURRENTPOS to get the position.
if (notification->position != -1)
position_of_click = notification->position;
else
position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS));
// Anonymous scope to limit use of the buf pointer (much easier to deal with std::string).
{
@ -499,13 +506,6 @@ BOOL Notepad_plus::notify(SCNotification *notification)
length = notifyView->execute(SCI_GETLENGTH);
buf = new char[length + 1];
notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf);
// For some reason Ctrl+DoubleClick on an empty line means that notification->position == 1.
// In that case we use SCI_GETCURRENTPOS to get the position.
if(notification->position != -1)
position_of_click = notification->position;
else
position_of_click = int(_pEditView->execute(SCI_GETCURRENTPOS));
}
else
{
@ -516,7 +516,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
// Compute the position of the click (relative to the beginning of the line).
const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber());
position_of_click = notification->position - line_position;
position_of_click = position_of_click - line_position;
}
bufstring = buf;