Merge pull request #5042 from RaiKoHoff/Dev_Master

Fix: VS Studio line-cut behavior on empty selection
This commit is contained in:
Pairi Daiza 2023-10-20 10:18:26 +02:00 committed by GitHub
commit 6ceab2e5b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -2949,14 +2949,21 @@ static int utsort_ln(const void *a, const void *b) {
return (_a < _b) ? -1 : ((_a > _b) ? 1 : 0);
}
void EditCutLines(HWND hwnd)
void EditCutLines(HWND hwnd, const bool bMSBehavSelEmpty)
{
if (!Sci_IsMultiOrRectangleSelection())
{
bool const bInLastLine = Sci_InLastLine();
bool const bClearCB = bInLastLine ? (Sci_GetNetLineLength(Sci_GetCurrentLineNumber()) == 0) : false;
UndoTransActionBegin();
SciCall_LineCut();
if (SciCall_IsSelectionEmpty() && bMSBehavSelEmpty) {
SciCall_CopyAllowLine(); // (!) VisualStudio behavior
// On Windows, an extra "MSDEVLineSelect" marker is added to the clipboard
// which is then used in SCI_PASTE to paste the whole line before the current line.
SciCall_LineDelete();
} else {
SciCall_LineCut();
}
if (bInLastLine) {
SciCall_DeleteBack();
SciCall_Home();

View File

@ -69,7 +69,7 @@ void EditMoveUp(HWND hwnd);
void EditMoveDown(HWND hwnd);
bool EditSetCaretToSelectionStart();
bool EditSetCaretToSelectionEnd();
void EditCutLines(HWND hwnd);
void EditCutLines(HWND hwnd, const bool bMSBehavSelEmpty);
void EditCopyMultiSelection(HWND hwnd);
void EditModifyLines(const PENCLOSESELDATA pEnclData);
void EditIndentBlock(HWND hwnd,int cmd, bool bFormatIndentation, bool bForceAll);

View File

@ -5143,7 +5143,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
}
EditDeleteMarkerInSelection();
if (SciCall_IsSelectionEmpty()) {
EditCutLines(Globals.hwndEdit);
EditCutLines(Globals.hwndEdit, true);
} else {
SciCall_Cut();
}
@ -5155,9 +5155,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
if (s_flagPasteBoard) {
s_bLastCopyFromMe = true;
}
// explicit(!): ignore (SciCall_IsSelectionEmpty()) && Settings2.NoCutLineOnEmptySelection)
//~ explicit(!): ignore (SciCall_IsSelectionEmpty()) && Settings2.NoCutLineOnEmptySelection)
EditDeleteMarkerInSelection();
EditCutLines(Globals.hwndEdit);
EditCutLines(Globals.hwndEdit, false);
}
break;