Use CRLF line ending in Copy command from Windows dialog
Also, move endsWith() function to Common.h and reuse it in WindowsDlg. Fix #10311, close #10314pull/10319/head
parent
ef1ecaa936
commit
90485aaa21
|
@ -1297,6 +1297,15 @@ void trim(generic_string& str)
|
|||
else str.erase(str.begin(), str.end());
|
||||
}
|
||||
|
||||
bool endsWith(const generic_string& s, const generic_string& suffix)
|
||||
{
|
||||
#if defined(_MSVC_LANG) && (_MSVC_LANG > 201402L)
|
||||
#error Replace this function with basic_string::ends_with
|
||||
#endif
|
||||
size_t pos = s.find(suffix);
|
||||
return pos != s.npos && ((s.length() - pos) == suffix.length());
|
||||
}
|
||||
|
||||
int nbDigitsFromNbLines(size_t nbLines)
|
||||
{
|
||||
int nbDigits = 0; // minimum number of digit should be 4
|
||||
|
|
|
@ -225,5 +225,6 @@ template<typename T> size_t vecRemoveDuplicates(std::vector<T>& vec, bool isSort
|
|||
}
|
||||
|
||||
void trim(generic_string& str);
|
||||
bool endsWith(const generic_string& s, const generic_string& suffix);
|
||||
|
||||
int nbDigitsFromNbLines(size_t nbLines);
|
||||
|
|
|
@ -90,15 +90,6 @@ namespace // anonymous
|
|||
return name.find_last_of('.') != generic_string::npos;
|
||||
}
|
||||
|
||||
bool endsWith(const generic_string& s, const generic_string& suffix)
|
||||
{
|
||||
#if defined(_MSVC_LANG) && (_MSVC_LANG > 201402L)
|
||||
#error Replace this function with basic_string::ends_with
|
||||
#endif
|
||||
size_t pos = s.find(suffix);
|
||||
return pos != s.npos && ((s.length() - pos) == suffix.length());
|
||||
}
|
||||
|
||||
void expandEnv(generic_string& s)
|
||||
{
|
||||
TCHAR buffer[MAX_PATH] = { 0 };
|
||||
|
|
|
@ -984,6 +984,7 @@ void WindowsDlg::putItemsToClipboard(bool isFullPath)
|
|||
constexpr int pathColumn = 1;
|
||||
|
||||
TCHAR str[MAX_PATH] = {};
|
||||
const generic_string crlf = _T("\r\n");
|
||||
|
||||
generic_string selection;
|
||||
for (int i = -1, j = 0; ; ++j)
|
||||
|
@ -1008,9 +1009,8 @@ void WindowsDlg::putItemsToClipboard(bool isFullPath)
|
|||
if (fileName)
|
||||
selection += fileName;
|
||||
}
|
||||
|
||||
if (!selection.empty() && selection.back() != '\n')
|
||||
selection += '\n';
|
||||
if (!selection.empty() && !endsWith(selection, crlf))
|
||||
selection += crlf;
|
||||
}
|
||||
if (!selection.empty())
|
||||
str2Clipboard(selection, _hList);
|
||||
|
|
Loading…
Reference in New Issue