Fix condition where Split Lines does one too many lines

Fix #8504, close #8507
This commit is contained in:
Scott Sumner 2020-07-01 19:50:20 -04:00 committed by Don HO
parent b935bc6bf3
commit 4bf662d031
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -1415,18 +1415,27 @@ void Notepad_plus::command(int id)
break; break;
case IDM_EDIT_SPLIT_LINES: case IDM_EDIT_SPLIT_LINES:
_pEditView->execute(SCI_TARGETFROMSELECTION); {
if (_pEditView->execute(SCI_GETEDGEMODE) == EDGE_NONE) pair<int, int> lineRange = _pEditView->getSelectionLinesRange();
if (lineRange.first != -1)
{ {
_pEditView->execute(SCI_LINESSPLIT); auto anchorPos = _pEditView->execute(SCI_POSITIONFROMLINE, lineRange.first);
auto caretPos = _pEditView->execute(SCI_GETLINEENDPOSITION, lineRange.second);
_pEditView->execute(SCI_SETSELECTION, caretPos, anchorPos);
_pEditView->execute(SCI_TARGETFROMSELECTION);
if (_pEditView->execute(SCI_GETEDGEMODE) == EDGE_NONE)
{
_pEditView->execute(SCI_LINESSPLIT);
}
else
{
auto textWidth = _pEditView->execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<LPARAM>("P"));
auto edgeCol = _pEditView->execute(SCI_GETEDGECOLUMN);
_pEditView->execute(SCI_LINESSPLIT, textWidth * edgeCol);
}
} }
else }
{ break;
auto textWidth = _pEditView->execute(SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<LPARAM>("P"));
auto edgeCol = _pEditView->execute(SCI_GETEDGECOLUMN);
_pEditView->execute(SCI_LINESSPLIT, textWidth * edgeCol);
}
break;
case IDM_EDIT_JOIN_LINES: case IDM_EDIT_JOIN_LINES:
_pEditView->execute(SCI_TARGETFROMSELECTION); _pEditView->execute(SCI_TARGETFROMSELECTION);