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,6 +1415,13 @@ void Notepad_plus::command(int id)
break; break;
case IDM_EDIT_SPLIT_LINES: case IDM_EDIT_SPLIT_LINES:
{
pair<int, int> lineRange = _pEditView->getSelectionLinesRange();
if (lineRange.first != -1)
{
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); _pEditView->execute(SCI_TARGETFROMSELECTION);
if (_pEditView->execute(SCI_GETEDGEMODE) == EDGE_NONE) if (_pEditView->execute(SCI_GETEDGEMODE) == EDGE_NONE)
{ {
@ -1426,6 +1433,8 @@ void Notepad_plus::command(int id)
auto edgeCol = _pEditView->execute(SCI_GETEDGECOLUMN); auto edgeCol = _pEditView->execute(SCI_GETEDGECOLUMN);
_pEditView->execute(SCI_LINESSPLIT, textWidth * edgeCol); _pEditView->execute(SCI_LINESSPLIT, textWidth * edgeCol);
} }
}
}
break; break;
case IDM_EDIT_JOIN_LINES: case IDM_EDIT_JOIN_LINES: