diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Editor.cxx | 5 | ||||
| -rw-r--r-- | src/Selection.cxx | 18 | ||||
| -rw-r--r-- | src/Selection.h | 1 | 
3 files changed, 23 insertions, 1 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 17076a373..602dcd884 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3766,6 +3766,7 @@ void Editor::ClearSelection() {  			}  		}  	} +	sel.RemoveDuplicates();  }  void Editor::ClearAll() { @@ -3878,6 +3879,7 @@ void Editor::Clear() {  	} else {  		ClearSelection();  	} +	sel.RemoveDuplicates();  }  void Editor::SelectAll() { @@ -3956,6 +3958,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) {  		}  		//SetEmptySelection(sel.MainCaret());  	} +	sel.RemoveDuplicates();  	// Avoid blinking during rapid typing:  	ShowCaretAtCurrentPosition();  } @@ -6444,7 +6447,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  			SelectionText selectedText;  			CopySelectionRange(&selectedText);  			if (lParam == 0) { -				return selectedText.len; +				return selectedText.len + 1;  			} else {  				char *ptr = CharPtrFromSPtr(lParam);  				int iChar = 0; diff --git a/src/Selection.cxx b/src/Selection.cxx index 43607b244..1ea5f1bbe 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -310,3 +310,21 @@ void Selection::Clear() {  	ranges[mainRange].Reset();  	rangeRectangular.Reset();  } + +void Selection::RemoveDuplicates() { +	for (size_t i=0; i<ranges.size()-1; i++) { +		if (ranges[i].Empty()) { +			size_t j=i+1; +			while (j<ranges.size()) { +				if (ranges[i] == ranges[j]) { +					ranges.erase(ranges.begin() + j); +					if (mainRange >= j) +						mainRange--; +				} else { +					j++; +				} +			} +		} +	} +} + diff --git a/src/Selection.h b/src/Selection.h index 9e5372638..2c4ee120b 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -155,6 +155,7 @@ public:  	int InSelectionForEOL(int pos) const;  	int VirtualSpaceFor(int pos) const;  	void Clear(); +	void RemoveDuplicates();  };  #ifdef SCI_NAMESPACE | 
