-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of the Issue
When pasting into multiple selections, mismatch of line ending formats prevents proper column selection pasting.
Steps To Reproduce
- Create or open a document and set the line ending format to UNIX. Select a column selection and press Ctrl+C to copy it.
- Create or open another document and set the line ending format to WINDOWS. Create multiple selections and press Ctrl+V to paste.
Current Behavior
The column selection text is only pasted into the first selection.
Expected Behavior
The clipboard text should be split using the line ending format detected from the clipboard content, allowing it to be pasted correctly into multiple selections.
@donho Relevant function:
bool ScintillaEditView::pasteToMultiSelection() const
{
// ...
stringSplit(clipboardStr, getEOLString(), clipboardStrings);
// ...
}
The stringSplit function is intended to split the clipboard content (which represents a column selection selection, separated by line endings) into multiple text segments for insertion into each selection.
However, the function getEOLString currently reads the line ending format from the current document, not from the clipboard text. Therefore, if the clipboard content and the current document have different line ending formats, the splitting will fail.
Suggested fix:
Add an overloaded function:
std::wstring ScintillaEditView::getEOLString(const std::wstring& str) const
{
size_t pos = str.find(L"\r\n");
if (pos != std::wstring::npos)
return L"\r\n";
pos = str.find(L"\n");
if (pos != std::wstring::npos)
return L"\n";
pos = str.find(L"\r");
if (pos != std::wstring::npos)
return L"\r";
auto eol_mode = _currentBuffer->getEolFormat();
switch (eol_mode)
{
case EolType::windows:
return L"\r\n";
case EolType::unix:
return L"\n";
default:
return L"\r";
}
}
Then use this overload to split the clipboard text:
stringSplit(clipboardStr, getEOLString(clipboardStr), clipboardStrings);
This will correctly handle line ending mismatches and fix the bug.
Debug Information
Notepad++ v8.8.1 (64-bit)
Build time : May 3 2025 - 18:41:09
Scintilla/Lexilla included : 5.5.6/5.4.4
Boost Regex included : 1_85
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
Scintilla Rendering Mode : SC_TECHNOLOGY_DEFAULT (0)
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 11 Pro (64-bit)
OS Version : 24H2
OS Build : 26100.4061
Current ANSI codepage : 1252
Plugins :
mimeTools (3.1)Anything else?
No response