Fix local variable shadows outer variable issues

This commit is contained in:
Don HO 2019-07-08 03:31:43 +02:00
parent 6ddbca3a60
commit 2d15d90e02
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
8 changed files with 25 additions and 54 deletions

View File

@ -2677,10 +2677,10 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
{
indentAmountPrevLine = _pEditView->getLineIndent(prevLine);
auto startPos = _pEditView->execute(SCI_POSITIONFROMLINE, prevLine);
auto endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, prevLine);
auto startPos2 = _pEditView->execute(SCI_POSITIONFROMLINE, prevLine);
auto endPos2 = _pEditView->execute(SCI_GETLINEENDPOSITION, prevLine);
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP | SCFIND_POSIX);
_pEditView->execute(SCI_SETTARGETRANGE, startPos, endPos);
_pEditView->execute(SCI_SETTARGETRANGE, startPos2, endPos2);
const char braceExpr[] = "[ \t]*\\{.*";
@ -2688,7 +2688,7 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
if (posFound != -1 && posFound != -2)
{
int end = int(_pEditView->execute(SCI_GETTARGETEND));
if (end == endPos)
if (end == endPos2)
indentAmountPrevLine += tabWidth;
}
}
@ -3253,7 +3253,6 @@ void Notepad_plus::dropFiles(HDROP hdrop)
switchEditViewTo(MAIN_VIEW);
int filesDropped = ::DragQueryFile(hdrop, 0xffffffff, NULL, 0);
BufferID lastOpened = BUFFER_INVALID;
vector<generic_string> folderPaths;
vector<generic_string> filePaths;
@ -3282,7 +3281,6 @@ void Notepad_plus::dropFiles(HDROP hdrop)
if (isOldMode || folderPaths.size() == 0) // old mode or new mode + only files
{
BufferID lastOpened = BUFFER_INVALID;
for (int i = 0; i < filesDropped; ++i)
{
@ -3313,10 +3311,6 @@ void Notepad_plus::dropFiles(HDROP hdrop)
launchFileBrowser(folderPaths);
}
if (lastOpened != BUFFER_INVALID)
{
switchToFile(lastOpened);
}
::DragFinish(hdrop);
// Put Notepad_plus to forefront
// May not work for Win2k, but OK for lower versions

View File

@ -234,8 +234,8 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
if (res == IDYES)
{
bool res = MainFileManager->createEmptyFile(longFileName);
if (res)
bool isOK = MainFileManager->createEmptyFile(longFileName);
if (isOK)
{
isCreateFileSuccessful = true;
}
@ -293,15 +293,15 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive,
if (buffer != BUFFER_INVALID)
{
bool isSnapshotMode = (backupFileName != NULL and PathFileExists(backupFileName));
isSnapshotMode = (backupFileName != NULL && ::PathFileExists(backupFileName));
if (isSnapshotMode)
{
// To notify plugins that a snapshot dirty file is loaded on startup
SCNotification scnN;
scnN.nmhdr.hwndFrom = 0;
scnN.nmhdr.idFrom = (uptr_t)buffer;
scnN.nmhdr.code = NPPN_SNAPSHOTDIRTYFILELOADED;
_pluginsManager.notify(&scnN);
SCNotification scnN2;
scnN2.nmhdr.hwndFrom = 0;
scnN2.nmhdr.idFrom = (uptr_t)buffer;
scnN2.nmhdr.code = NPPN_SNAPSHOTDIRTYFILELOADED;
_pluginsManager.notify(&scnN2);
buffer->setLoadedDirty(true);
}
@ -535,13 +535,13 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
generic_string args = TEXT("-multiInst");
size_t res = (size_t)::ShellExecute(_pPublicInterface->getHSelf(), TEXT("runas"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW);
size_t shellExecRes = (size_t)::ShellExecute(_pPublicInterface->getHSelf(), TEXT("runas"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW);
// If the function succeeds, it returns a value greater than 32. If the function fails,
// it returns an error value that indicates the cause of the failure.
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
if (res < 32)
if (shellExecRes < 32)
{
_nativeLangSpeaker.messageBox("OpenInAdminModeFailed",
_pPublicInterface->getHSelf(),
@ -579,13 +579,13 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
args += TEXT("\"");
args += fileNamePath;
args += TEXT("\"");
size_t res = (size_t)::ShellExecute(_pPublicInterface->getHSelf(), TEXT("runas"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW);
size_t shellExecRes = (size_t)::ShellExecute(_pPublicInterface->getHSelf(), TEXT("runas"), nppFullPath, args.c_str(), TEXT("."), SW_SHOW);
// If the function succeeds, it returns a value greater than 32. If the function fails,
// it returns an error value that indicates the cause of the failure.
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx
if (res < 32)
if (shellExecRes < 32)
{
_nativeLangSpeaker.messageBox("OpenInAdminModeFailed",
_pPublicInterface->getHSelf(),

View File

@ -471,15 +471,11 @@ BOOL Notepad_plus::notify(SCNotification *notification)
LPNMMOUSE lpnm = (LPNMMOUSE)notification;
if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE))
{
POINT p;
::GetCursorPos(&p);
HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE);
TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL);
}
else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT))
{
POINT p;
::GetCursorPos(&p);
MenuPosition & menuPos = getMenuPosition("edit-eolConversion");
HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x);
if (!hEditMenu)

View File

@ -2836,15 +2836,7 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const generic_string
if (!isOK)
return false;
}
/*
// session.xml: Session stock the absolute file path, it should never be on cloud
generic_string cloudSessionPath = cloudSettingsPath;
PathAppend(cloudSessionPath, TEXT("session.xml"));
if (!::PathFileExists(cloudSessionPath.c_str()) && _pXmlSessionDoc)
{
_pXmlSessionDoc->SaveFile(cloudSessionPath.c_str());
}
*/
// userDefineLang.xml
generic_string cloudUserLangsPath = cloudSettingsPath;
PathAppend(cloudUserLangsPath, TEXT("userDefineLang.xml"));
@ -2885,15 +2877,6 @@ bool NppParameters::writeSettingsFilesOnCloudForThe1stTime(const generic_string
return false;
}
/*
// functionList.xml
generic_string cloudFunctionListPath = cloudSettingsPath;
PathAppend(cloudFunctionListPath, TEXT("functionList.xml"));
if (!::PathFileExists(cloudFunctionListPath.c_str()))
{
}
*/
return true;
}
@ -6429,8 +6412,8 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g
for (size_t x = 0; x < _pXmlExternalLexerDoc.size(); ++x)
{
TiXmlNode *lexersRoot = ( _pXmlExternalLexerDoc[x]->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles"));
for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType"));
TiXmlNode* lexersRoot2 = ( _pXmlExternalLexerDoc[x]->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles"));
for (TiXmlNode* childNode = lexersRoot2->FirstChildElement(TEXT("LexerType"));
childNode ;
childNode = childNode->NextSibling(TEXT("LexerType")))
{

View File

@ -834,9 +834,9 @@ void WordStyleDlg::setVisualFromStyleList()
LangType lType = pNppParams->getLangIDFromStr(lexerStyler.getLexerName());
if (lType == L_TEXT)
{
generic_string str = lexerStyler.getLexerName();
str += TEXT(" is not defined in NppParameters::getLangIDFromStr()");
printStr(str.c_str());
generic_string lexerNameStr = lexerStyler.getLexerName();
lexerNameStr += TEXT(" is not defined in NppParameters::getLangIDFromStr()");
printStr(lexerNameStr.c_str());
}
const TCHAR *kws = pNppParams->getWordList(lType, style._keywordClass);
if (!kws)

View File

@ -1106,10 +1106,10 @@ void DockingCont::onSize()
// get active item data
size_t iItemCnt = static_cast<size_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
size_t iItemCnt2 = static_cast<size_t>(::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0));
// resize visible plugin windows
for (size_t iItem = 0; iItem < iItemCnt; ++iItem)
for (size_t iItem = 0; iItem < iItemCnt2; ++iItem)
{
tcItem.mask = TCIF_PARAM;
::SendMessage(_hContTab, TCM_GETITEM, iItem, reinterpret_cast<LPARAM>(&tcItem));

View File

@ -350,7 +350,7 @@ void FunctionListPanel::reload()
if (root)
{
Buffer* currentBuf = (*_ppEditView)->getCurrentBuffer();
currentBuf = (*_ppEditView)->getCurrentBuffer();
const TCHAR *fullFilePath = currentBuf->getFullPathName();
_treeView.setItemParam(root, fullFilePath);
TreeParams *previousParams = getFromStateArray(fullFilePath);

View File

@ -808,8 +808,6 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
case IDC_COLONENUMBER_STATIC:
{
ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP();
NativeLangSpeaker *pNativeSpeaker = pNppParam->getNativeLangSpeaker();
generic_string strNbCol = pNativeSpeaker->getLocalizedStrFromID("edit-verticaledge-nb-col", TEXT("Nb of column:"));