[BUG_FIXED] Fix the word-compltion hanging problem in Chinese ANSI document.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1193 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 11 years ago
parent b63c4a0f6c
commit 98cf4f3abd

@ -934,7 +934,7 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
_invisibleEditView.execute(SCI_SETTARGETEND, endPos);
int posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(xmlHeaderRegExpr), (LPARAM)xmlHeaderRegExpr);
if (posFound != -1)
if (posFound != -1 && posFound != -2)
{
const char *encodingBlockRegExpr = "encoding[ \\t]*=[ \\t]*\"[^\".]+\"";
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(encodingBlockRegExpr), (LPARAM)encodingBlockRegExpr);
@ -973,10 +973,10 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
int posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), (LPARAM)htmlHeaderRegExpr);
if (posFound == -1)
if (posFound == -1 || posFound == -2)
{
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), (LPARAM)htmlHeaderRegExpr2);
if (posFound == -1)
if (posFound == -1 || posFound == -2)
return -1;
}
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(charsetBlock), (LPARAM)charsetBlock);
@ -2176,7 +2176,7 @@ void Notepad_plus::addHotSpot()
int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR);
while (posFound != -1)
while (posFound != -1 && posFound != -2)
{
int start = int(_pEditView->execute(SCI_GETTARGETSTART));
int end = int(_pEditView->execute(SCI_GETTARGETEND));
@ -5400,7 +5400,7 @@ Quote quotes[nbQuote] = {
{"Anonymous #96", "Code for 6 minutes, debug for 6 hours."},
{"Anonymous #97", "Real Programmers don't comment their code.\nIf it was hard to write, it should be hard to read."},
{"Anonymous #98", "My neighbours listen to good music.\nWhether they like it or not."},
{"Anonymous #99", "Mondays are not so bad.\nIt's your job that sucks."},
{"Anonymous #99", "I've been using Vim for about 2 years now,\nmostly because I can't figure out how to exit it."},
{"Anonymous #100", "Dear YouTube,\nI can deal with Ads.\nI can deal with Buffer.\nBut when Ads buffer, I suffer."},
{"Anonymous #101", "It's always sad when a man and his dick share only one brain...\nand it turns out to be the dick's."},
{"Anonymous #102", "If IE is brave enough to ask you to set it as your default browser,\ndon't tell me you dare not ask a girl out."},
@ -5425,7 +5425,7 @@ Quote quotes[nbQuote] = {
{"Anonymous #121", "Thing to do today:\n1. Get up\n2. Go back to bed"},
{"Anonymous #122", "Nerd?\nI prefer the term \"Intellectual badass\"."},
{"Anonymous #123", "How can you face your problem if your problem is your face?"},
{"Anonymous #124", "YOLOLO:\nYou Only LOL Once."},
//{"Anonymous #124", ""},
{"Anonymous #125", "Pooping with the door opened is the meaning of true freedom."},
{"Anonymous #126", "Social media does not make people stupid.\nIt just makes stupid people more visible."},
{"Anonymous #127", "Don't give up your dreams.\nKeep sleeping."},
@ -5445,6 +5445,7 @@ Quote quotes[nbQuote] = {
{"Anonymous #141", "To most religious people, the holy books are like a software license (EULA).\nNobody actually reads it. They just scroll to the bottom and click \"I agree\"."},
{"Anonymous #142", "You are nothing but a number of days,\nwhenever each day passes then part of you has gone."},
{"Anonymous #143", "If 666 is evil, does that make 25.8069758011 the root of all evil?"},
{"Floor", "If you fall, I will be there."},
{"Simon Amstell", "If you have some problem in your life and need to deal with it, then use religion, that's fine.\nI use Google."},
{"James Bond", "James, James Bond."},
{"Albert Einstein", "Only 3 things are infinite:\n1. Universe.\n2. Human Stupidity.\n3. Winrar's free trial."},

@ -765,28 +765,31 @@ BOOL Notepad_plus::notify(SCNotification *notification)
notifyView->execute(SCI_SETTARGETEND, endPos);
int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(URL_REG_EXPR), (LPARAM)URL_REG_EXPR);
if (posFound != -1)
if (posFound != -2)
{
startPos = int(notifyView->execute(SCI_GETTARGETSTART));
endPos = int(notifyView->execute(SCI_GETTARGETEND));
}
if (posFound != -1)
{
startPos = int(notifyView->execute(SCI_GETTARGETSTART));
endPos = int(notifyView->execute(SCI_GETTARGETEND));
}
// Prevent buffer overflow in getGenericText().
if(endPos - startPos > 2*MAX_PATH)
endPos = startPos + 2*MAX_PATH;
// Prevent buffer overflow in getGenericText().
if(endPos - startPos > 2*MAX_PATH)
endPos = startPos + 2*MAX_PATH;
TCHAR currentWord[2*MAX_PATH];
TCHAR currentWord[2*MAX_PATH];
notifyView->getGenericText(currentWord, MAX_PATH*2, startPos, endPos);
notifyView->getGenericText(currentWord, MAX_PATH*2, startPos, endPos);
// This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end.
int lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1;
if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '('))
currentWord[lastCharIndex] = '\0';
// This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end.
int lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1;
if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '('))
currentWord[lastCharIndex] = '\0';
::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), currentWord, NULL, NULL, SW_SHOW);
_isHotspotDblClicked = true;
notifyView->execute(SCI_SETCHARSDEFAULT);
::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), currentWord, NULL, NULL, SW_SHOW);
_isHotspotDblClicked = true;
notifyView->execute(SCI_SETCHARSDEFAULT);
}
break;
}

@ -127,16 +127,14 @@ void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beg
int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX;
_pEditView->execute(SCI_SETSEARCHFLAGS, flags);
int posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), 0, docLength);
while (posFind != -1)
while (posFind != -1 && posFind != -2)
{
int wordStart = int(_pEditView->execute(SCI_GETTARGETSTART));
int wordEnd = int(_pEditView->execute(SCI_GETTARGETEND));
size_t foundTextLen = wordEnd - wordStart;
size_t foundTextLen = wordEnd - wordStart;
if (foundTextLen < bufSize)
{
TCHAR w[bufSize];
@ -491,18 +489,7 @@ void AutoCompletion::update(int character)
if (lstrlen(s) >= int(nppGUI._autocFromLen))
{
if (nppGUI._autocStatus == nppGUI.autoc_word)
{
// Walk around - to avoid the crash under Chinese Windows7 ANSI doc mode
if (!_pEditView->isCJK())
{
showWordComplete(false);
}
else
{
if ((_pEditView->getCurrentBuffer())->getUnicodeMode() != uni8Bit)
showWordComplete(false);
}
}
showWordComplete(false);
else if (nppGUI._autocStatus == nppGUI.autoc_func)
showApiComplete();
else if (nppGUI._autocStatus == nppGUI.autoc_both)

Loading…
Cancel
Save