From a4fd0c4d16a1f20e6bed527d082fa9208180ce04 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Fri, 20 Oct 2023 09:22:16 +0200 Subject: [PATCH 1/2] +fix: VS Studio line-cut behavior on empty selection --- src/Edit.c | 9 ++++++++- src/Notepad3.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index c9fda17eb..836de28af 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -2956,7 +2956,14 @@ void EditCutLines(HWND hwnd) bool const bInLastLine = Sci_InLastLine(); bool const bClearCB = bInLastLine ? (Sci_GetNetLineLength(Sci_GetCurrentLineNumber()) == 0) : false; UndoTransActionBegin(); - SciCall_LineCut(); + if (SciCall_IsSelectionEmpty()) { + 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(); diff --git a/src/Notepad3.c b/src/Notepad3.c index 34f081a9a..76574b657 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -5155,7 +5155,7 @@ 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); } From 13e19ec5f2093cecfbc94f3357774ca48bd8b57c Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Fri, 20 Oct 2023 09:33:15 +0200 Subject: [PATCH 2/2] +fix: behavior of Ctrl+Shift+X --- src/Edit.c | 4 ++-- src/Edit.h | 2 +- src/Notepad3.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 836de28af..00419ad8c 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -2949,14 +2949,14 @@ 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(); - if (SciCall_IsSelectionEmpty()) { + 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. diff --git a/src/Edit.h b/src/Edit.h index cb2aefe76..a307ae3f8 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -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); diff --git a/src/Notepad3.c b/src/Notepad3.c index 76574b657..d6dc2a49b 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -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(); } @@ -5157,7 +5157,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) } //~ explicit(!): ignore (SciCall_IsSelectionEmpty()) && Settings2.NoCutLineOnEmptySelection) EditDeleteMarkerInSelection(); - EditCutLines(Globals.hwndEdit); + EditCutLines(Globals.hwndEdit, false); } break;