From 1aa01f95869bae53f52a501b7970977c6963f8cc Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 11 Oct 2009 05:45:27 +0000 Subject: Fix bug #2871358 where left or right key with rectangular selection moved to a left or right of main selection rather than before or after rectangular selection. --- src/Editor.cxx | 4 ++-- src/Selection.cxx | 13 +++++++++++++ src/Selection.h | 7 +++++++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index 61008613d..45cf73bec 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4685,7 +4685,7 @@ int Editor::KeyCommand(unsigned int iMessage) { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1)); } } else { - MovePositionTo(sel.RangeMain().Start()); + MovePositionTo(sel.IsRectangular() ? sel.Limits().start : sel.RangeMain().Start()); } SetLastXChosen(); break; @@ -4719,7 +4719,7 @@ int Editor::KeyCommand(unsigned int iMessage) { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1)); } } else { - MovePositionTo(sel.RangeMain().End()); + MovePositionTo(sel.IsRectangular() ? sel.Limits().end : sel.RangeMain().End()); } SetLastXChosen(); break; diff --git a/src/Selection.cxx b/src/Selection.cxx index 47d078675..566cb1074 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -179,6 +179,19 @@ SelectionRange &Selection::Rectangular() { return rangeRectangular; } +SelectionSegment Selection::Limits() const { + if (ranges.empty()) { + return SelectionSegment(); + } else { + SelectionSegment sr(ranges[0].anchor, ranges[0].caret); + for (size_t i=1; i p) + start = p; + if (end < p) + end = p; + } }; struct SelectionRange { @@ -141,6 +147,7 @@ public: int MainCaret() const; int MainAnchor() const; SelectionRange &Rectangular(); + SelectionSegment Limits() const; size_t Count() const; size_t Main() const; void SetMain(size_t r); -- cgit v1.2.3