aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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;
}