diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index 9a6066094..7f04a2627 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -158,7 +158,7 @@ The comments are here for explanation, it's not necessary to translate them.
-
+
diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml
index 4179228ca..59caa56a7 100644
--- a/PowerEditor/installer/nativeLang/english_customizable.xml
+++ b/PowerEditor/installer/nativeLang/english_customizable.xml
@@ -150,7 +150,7 @@
-
+
diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp
index 5811b1391..44e6f916f 100644
--- a/PowerEditor/src/Notepad_plus.cpp
+++ b/PowerEditor/src/Notepad_plus.cpp
@@ -1493,11 +1493,13 @@ void Notepad_plus::doTrim(trimOp whichPart)
env._searchType = FindRegex;
auto mainSelAnchor = _pEditView->execute(SCI_GETANCHOR);
auto mainSelCaretPos = _pEditView->execute(SCI_GETCURRENTPOS);
- auto rectSelAnchorVirt = _pEditView->execute(SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE);
- auto rectSelCaretVirt = _pEditView->execute(SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE);
- bool isRectSel = (_pEditView->execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (_pEditView->execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN);
- bool isEntireDoc = (mainSelAnchor == mainSelCaretPos) && (rectSelAnchorVirt == rectSelCaretVirt);
+ bool isEntireDoc = (mainSelAnchor == mainSelCaretPos);
auto docLength = _pEditView->execute(SCI_GETLENGTH);
+
+ // block selection is not supported
+ if ((_pEditView->execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (_pEditView->execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN))
+ return;
+
// auto-expand of partially selected lines
if (!isEntireDoc)
{
@@ -1516,24 +1518,27 @@ void Notepad_plus::doTrim(trimOp whichPart)
_pEditView->execute(SCI_SETSEL, startPos, endPos);
}
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
+
// restore original selection if nothing has changed
if (!isEntireDoc && (docLength == _pEditView->execute(SCI_GETLENGTH)))
{
- if (isRectSel)
- {
- _pEditView->execute(SCI_SETRECTANGULARSELECTIONANCHOR, mainSelAnchor);
- _pEditView->execute(SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, rectSelAnchorVirt);
- _pEditView->execute(SCI_SETRECTANGULARSELECTIONCARET, mainSelCaretPos);
- _pEditView->execute(SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, rectSelCaretVirt);
- }
- else
- {
_pEditView->execute(SCI_SETANCHOR, mainSelAnchor);
_pEditView->execute(SCI_SETCURRENTPOS, mainSelCaretPos);
- }
}
}
+void Notepad_plus::eol2ws()
+{
+ bool isEntireDoc = (_pEditView->execute(SCI_GETANCHOR) == _pEditView->execute(SCI_GETCURRENTPOS));
+
+ // block selection is not supported
+ if ((_pEditView->execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (_pEditView->execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN))
+ return;
+
+ _pEditView->execute(isEntireDoc ? SCI_TARGETWHOLEDOCUMENT: SCI_TARGETFROMSELECTION);
+ _pEditView->execute(SCI_LINESJOIN);
+}
+
void Notepad_plus::removeEmptyLine(bool isBlankContained)
{
// whichPart : line head or line tail
diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h
index a6681caa8..9d0107fcf 100644
--- a/PowerEditor/src/Notepad_plus.h
+++ b/PowerEditor/src/Notepad_plus.h
@@ -599,6 +599,7 @@ private:
void wsTabConvert(spaceTab whichWay);
void doTrim(trimOp whichPart);
+ void eol2ws();
void removeEmptyLine(bool isBlankContained);
void removeDuplicateLines();
void launchAnsiCharPanel();
diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc
index 07f7ac106..91c478e61 100644
--- a/PowerEditor/src/Notepad_plus.rc
+++ b/PowerEditor/src/Notepad_plus.rc
@@ -524,7 +524,7 @@ BEGIN
MENUITEM "Trim Leading Space", IDM_EDIT_TRIMLINEHEAD
MENUITEM "Trim Leading and Trailing Space", IDM_EDIT_TRIM_BOTH
MENUITEM "EOL to Space", IDM_EDIT_EOL2WS
- MENUITEM "Remove Unnecessary Blank and EOL", IDM_EDIT_TRIMALL
+ MENUITEM "Trim both and EOL to Space", IDM_EDIT_TRIMALL
MENUITEM SEPARATOR
MENUITEM "TAB to Space", IDM_EDIT_TAB2SW
MENUITEM "Space to TAB (All)", IDM_EDIT_SW2TAB_ALL
diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp
index f8a41eb38..c65c3a2f0 100644
--- a/PowerEditor/src/NppCommands.cpp
+++ b/PowerEditor/src/NppCommands.cpp
@@ -1909,8 +1909,7 @@ void Notepad_plus::command(int id)
case IDM_EDIT_EOL2WS:
_pEditView->execute(SCI_BEGINUNDOACTION);
- _pEditView->execute(SCI_TARGETWHOLEDOCUMENT);
- _pEditView->execute(SCI_LINESJOIN);
+ eol2ws();
_pEditView->execute(SCI_ENDUNDOACTION);
break;
@@ -1919,9 +1918,10 @@ void Notepad_plus::command(int id)
std::lock_guard lock(command_mutex);
_pEditView->execute(SCI_BEGINUNDOACTION);
+ bool isEntireDoc = _pEditView->execute(SCI_GETANCHOR) == _pEditView->execute(SCI_GETCURRENTPOS);
doTrim(lineBoth);
- _pEditView->execute(SCI_TARGETWHOLEDOCUMENT);
- _pEditView->execute(SCI_LINESJOIN);
+ if (isEntireDoc || _pEditView->execute(SCI_GETANCHOR) != _pEditView->execute(SCI_GETCURRENTPOS))
+ eol2ws();
_pEditView->execute(SCI_ENDUNDOACTION);
break;
}