From 5e3313d8a5070b79e96a5925e4e5854f73d3ed19 Mon Sep 17 00:00:00 2001 From: dail8859 Date: Thu, 14 Jan 2016 17:23:09 -0500 Subject: [PATCH] Selection start is gauranteed to return the smaller of the two positions Closes #1373 --- PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp | 9 ++------- PowerEditor/src/ScitillaComponent/ScintillaEditView.h | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index d44416409..0fa8c0a6c 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2372,12 +2372,7 @@ pair ScintillaEditView::getSelectionLinesRange() const range.first = execute(SCI_LINEFROMPOSITION, start); range.second = execute(SCI_LINEFROMPOSITION, end); - if (range.first > range.second) - { - int temp = range.first; - range.first = range.second; - range.second = temp; - } + return range; } @@ -2448,7 +2443,7 @@ void ScintillaEditView::convertSelectedTextTo(bool Case) size_t selectionStart = execute(SCI_GETSELECTIONSTART); size_t selectionEnd = execute(SCI_GETSELECTIONEND); - int strSize = ((selectionEnd > selectionStart)?(selectionEnd - selectionStart):(selectionStart - selectionEnd))+1; + int strSize = (selectionEnd - selectionStart) + 1; if (strSize) { char *selectedStr = new char[strSize+1]; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 14a893fff..c3b182582 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -466,11 +466,11 @@ public: return false; long start = long(execute(SCI_GETSELECTIONSTART)); long end = long(execute(SCI_GETSELECTIONEND)); - selByte = (start < end)?end-start:start-end; + selByte = end - start; start = long(execute(SCI_LINEFROMPOSITION, start)); end = long(execute(SCI_LINEFROMPOSITION, end)); - selLine = (start < end)?end-start:start-end; + selLine = end - start; if (selLine) ++selLine;