aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorpawelzwronek <unknown>2024-11-24 15:44:34 +0100
committerpawelzwronek <unknown>2024-11-24 15:44:34 +0100
commit19a8d747a56e7cb9e543cb807cf08fd95f3d617a (patch)
tree8e62b23dbbb96aa9301eaa108ca529470596703f
parent96a4a55dc33a3d51dc7fe94228f39fcd013124af (diff)
downloadscintilla-mirror-19a8d747a56e7cb9e543cb807cf08fd95f3d617a.tar.gz
Bug [#2457]. Fix moving line down to empty final line and moving empty final
line up. Handle edge cases when moving selected lines. Allow moving the selection when the end line of the document is empty or when moving up the last empty line.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--src/Editor.cxx10
2 files changed, 11 insertions, 3 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 84cbab7ad..471fc9a3a 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -611,6 +611,10 @@
<a href="https://sourceforge.net/p/scintilla/bugs/2456/">Bug #2456</a>.
</li>
<li>
+ Fix moving line down to empty final line and moving empty final line up.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2457/">Bug #2457</a>.
+ </li>
+ <li>
On GTK, allow middle click to insert multiple times within a document.
<a href="https://github.com/geany/geany/issues/2629">Geany Issue #2629</a>.
</li>
diff --git a/src/Editor.cxx b/src/Editor.cxx
index bd5a0b2c1..b60d96643 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1003,21 +1003,25 @@ void Editor::MoveSelectedLines(int lineDelta) {
// if selection doesn't end at the beginning of a line greater than that of the start,
// then set it at the beginning of the next one
Sci::Position selectionEnd = SelectionEnd().Position();
- const Sci::Line endLine = pdoc->SciLineFromPosition(selectionEnd);
+ Sci::Line endLine = pdoc->SciLineFromPosition(selectionEnd);
const Sci::Position beginningOfEndLine = pdoc->LineStart(endLine);
bool appendEol = false;
if (selectionEnd > beginningOfEndLine
|| selectionStart == selectionEnd) {
selectionEnd = pdoc->LineStart(endLine + 1);
appendEol = (selectionEnd == pdoc->Length() && pdoc->SciLineFromPosition(selectionEnd) == endLine);
+ endLine = pdoc->SciLineFromPosition(selectionEnd);
}
// if there's nowhere for the selection to move
// (i.e. at the beginning going up or at the end going down),
// stop it right there!
+ const bool docEndLineEmpty = pdoc->LineStart(endLine) == pdoc->Length();
if ((selectionStart == 0 && lineDelta < 0)
- || (selectionEnd == pdoc->Length() && lineDelta > 0)
- || selectionStart == selectionEnd) {
+ || (selectionEnd == pdoc->Length() && lineDelta > 0
+ && !docEndLineEmpty) // allow moving when end line of document is empty
+ || ((selectionStart == selectionEnd)
+ && !(lineDelta < 0 && docEndLineEmpty && selectionEnd == pdoc->Length()))) { // allow moving-up last empty line
return;
}