diff options
| author | nyamatongwe <devnull@localhost> | 2009-08-16 00:30:54 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2009-08-16 00:30:54 +0000 | 
| commit | 2ba263d420359bd3d529d2d32df0314b8253556d (patch) | |
| tree | b30b0d8020558f6fdcc0d92b0f5128fd07c59162 | |
| parent | 1847111186e5808fc17d22327756250165a02bac (diff) | |
| download | scintilla-mirror-2ba263d420359bd3d529d2d32df0314b8253556d.tar.gz | |
Always copy rectangular selections in ascending order.
| -rw-r--r-- | src/Editor.cxx | 8 | ||||
| -rw-r--r-- | src/Selection.h | 6 | 
2 files changed, 12 insertions, 2 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 3f7c9db0f..4df7c9247 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -12,6 +12,7 @@  #include <string>  #include <vector> +#include <algorithm>  // With Borland C++ 5.5, including <string> includes Windows.h leading to defining  // FindText to FindTextA which makes calls here to Document::FindText fail. @@ -5345,8 +5346,11 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {  		int size = sel.Length() + delimiterLength * sel.Count();  		char *text = new char[size + 1];  		int j = 0; -		for (size_t r=0; r<sel.Count(); r++) { -			SelectionRange current = sel.Range(r); +		std::vector<SelectionRange> rangesInOrder = sel.RangesCopy(); +		if (sel.selType == Selection::selRectangle) +			std::sort(rangesInOrder.begin(), rangesInOrder.end()); +		for (size_t r=0; r<rangesInOrder.size(); r++) { +			SelectionRange current = rangesInOrder[r];  			for (int i = current.Start().Position();  			        i < current.End().Position();  			        i++) { diff --git a/src/Selection.h b/src/Selection.h index c18e5c02e..b0c286866 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -98,6 +98,9 @@ struct SelectionRange {  	bool operator ==(const SelectionRange &other) const {  		return caret == other.caret && anchor == other.anchor;  	} +	bool operator <(const SelectionRange &other) const { +		return caret < other.caret || ((caret == other.caret) && (anchor < other.anchor)); +	}  	void Reset() {  		anchor.Reset();  		caret.Reset(); @@ -161,6 +164,9 @@ public:  	void RemoveDuplicates();  	void RotateMain();  	bool Tentative() const { return tentativeMain; } +	std::vector<SelectionRange> RangesCopy() const { +		return ranges; +	}  };  #ifdef SCI_NAMESPACE | 
