diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
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; } |