Fix find in files failure issue due to directory path with leading/trailing spaces
Trim spaces on Directory for FindInFiles to fix such issue. Fix #9199, close #9208
This commit is contained in:
parent
876a0c4c5a
commit
b2387286b1
@ -1327,3 +1327,17 @@ void getFilesInFolder(std::vector<generic_string>& files, const generic_string&
|
|||||||
::FindClose(hFindFile);
|
::FindClose(hFindFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void trim(generic_string& str)
|
||||||
|
{
|
||||||
|
// remove any leading or trailing spaces from str
|
||||||
|
|
||||||
|
generic_string::size_type pos = str.find_last_not_of(' ');
|
||||||
|
|
||||||
|
if (pos != generic_string::npos)
|
||||||
|
{
|
||||||
|
str.erase(pos + 1);
|
||||||
|
pos = str.find_first_not_of(' ');
|
||||||
|
if (pos != generic_string::npos) str.erase(0, pos);
|
||||||
|
}
|
||||||
|
else str.erase(str.begin(), str.end());
|
||||||
|
};
|
||||||
|
@ -233,3 +233,5 @@ template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSort
|
|||||||
}
|
}
|
||||||
return vec.size();
|
return vec.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void trim(generic_string& str);
|
||||||
|
@ -1238,11 +1238,15 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
_options._filters = filters;
|
_options._filters = filters;
|
||||||
|
|
||||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
||||||
addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
|
||||||
_options._directory = directory;
|
_options._directory = directory;
|
||||||
|
trim(_options._directory);
|
||||||
if ((lstrlen(directory) > 0) && (directory[lstrlen(directory)-1] != '\\'))
|
if (!_options._directory.empty())
|
||||||
|
{
|
||||||
|
addText2Combo(_options._directory.c_str(), ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
||||||
|
if (_options._directory.back() != L'\\')
|
||||||
|
{
|
||||||
_options._directory += TEXT("\\");
|
_options._directory += TEXT("\\");
|
||||||
|
}
|
||||||
|
|
||||||
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||||
combo2ExtendedMode(IDFINDWHAT);
|
combo2ExtendedMode(IDFINDWHAT);
|
||||||
@ -1254,6 +1258,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
findAllIn(FILES_IN_DIR);
|
findAllIn(FILES_IN_DIR);
|
||||||
nppParamInst._isFindReplacing = false;
|
nppParamInst._isFindReplacing = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDD_FINDINFILES_REPLACEINFILES:
|
case IDD_FINDINFILES_REPLACEINFILES:
|
||||||
@ -1269,14 +1274,18 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
_options._filters = filters;
|
_options._filters = filters;
|
||||||
|
|
||||||
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, MAX_PATH);
|
||||||
addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
|
||||||
_options._directory = directory;
|
_options._directory = directory;
|
||||||
|
trim(_options._directory);
|
||||||
if ((lstrlen(directory) > 0) && (directory[lstrlen(directory)-1] != '\\'))
|
if (!_options._directory.empty())
|
||||||
_options._directory += TEXT("\\");
|
{
|
||||||
|
|
||||||
if (replaceInFilesConfirmCheck(_options._directory, _options._filters))
|
if (replaceInFilesConfirmCheck(_options._directory, _options._filters))
|
||||||
{
|
{
|
||||||
|
addText2Combo(_options._directory.c_str(), ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO));
|
||||||
|
if (_options._directory.back() != L'\\')
|
||||||
|
{
|
||||||
|
_options._directory += TEXT("\\");
|
||||||
|
}
|
||||||
|
|
||||||
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||||
_options._str2Search = getTextFromCombo(hFindCombo);
|
_options._str2Search = getTextFromCombo(hFindCombo);
|
||||||
HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH);
|
HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH);
|
||||||
@ -1290,6 +1299,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
nppParamInst._isFindReplacing = false;
|
nppParamInst._isFindReplacing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDC_REPLACE_OPENEDFILES :
|
case IDC_REPLACE_OPENEDFILES :
|
||||||
|
@ -2102,19 +2102,6 @@ INT_PTR CALLBACK Highlighting::run_dlgProc(UINT message, WPARAM wParam, LPARAM/*
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void trim(generic_string & str)
|
|
||||||
{
|
|
||||||
generic_string::size_type pos = str.find_last_not_of(' ');
|
|
||||||
|
|
||||||
if (pos != generic_string::npos)
|
|
||||||
{
|
|
||||||
str.erase(pos + 1);
|
|
||||||
pos = str.find_first_not_of(' ');
|
|
||||||
if (pos != generic_string::npos) str.erase(0, pos);
|
|
||||||
}
|
|
||||||
else str.erase(str.begin(), str.end());
|
|
||||||
};
|
|
||||||
|
|
||||||
INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
||||||
{
|
{
|
||||||
NppParameters& nppParam = NppParameters::getInstance();
|
NppParameters& nppParam = NppParameters::getInstance();
|
||||||
|
Loading…
Reference in New Issue
Block a user