diff options
| -rw-r--r-- | src/Editor.cxx | 15 | ||||
| -rw-r--r-- | src/Editor.h | 1 | 
2 files changed, 11 insertions, 5 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index 3d5257059..1a591b325 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6152,6 +6152,11 @@ Window::Cursor Editor::GetMarginCursor(Point pt) {  	return Window::cursorReverseArrow;  } +void Editor::TrimAndSetSelection(int currentPos_, int anchor_) { +	sel.TrimSelection(SelectionRange(currentPos_, anchor_)); +	SetSelection(currentPos_, anchor_); +} +  void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine) {  	int selCurrentPos, selAnchorPos;  	if (wholeLine) { @@ -6182,7 +6187,7 @@ void Editor::LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLi  			selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true);  		}  	} -	SetSelection(selCurrentPos, selAnchorPos); +	TrimAndSetSelection(selCurrentPos, selAnchorPos);  }  void Editor::WordSelection(int pos) { @@ -6192,20 +6197,20 @@ void Editor::WordSelection(int pos) {  		// This ensures that a series of empty lines isn't counted as a single "word".  		if (!pdoc->IsLineEndPosition(pos))  			pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos + 1, 1), -1); -		SetSelection(pos, wordSelectAnchorEndPos); +		TrimAndSetSelection(pos, wordSelectAnchorEndPos);  	} else if (pos > wordSelectAnchorEndPos) {  		// Extend forward to the word containing the character to the left of pos.  		// Skip ExtendWordSelect if the line is empty or if pos is the first position on the line.  		// This ensures that a series of empty lines isn't counted as a single "word".  		if (pos > pdoc->LineStart(pdoc->LineFromPosition(pos)))  			pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos - 1, -1), 1); -		SetSelection(pos, wordSelectAnchorStartPos); +		TrimAndSetSelection(pos, wordSelectAnchorStartPos);  	} else {  		// Select only the anchored word  		if (pos >= originalAnchorPos) -			SetSelection(wordSelectAnchorEndPos, wordSelectAnchorStartPos); +			TrimAndSetSelection(wordSelectAnchorEndPos, wordSelectAnchorStartPos);  		else -			SetSelection(wordSelectAnchorStartPos, wordSelectAnchorEndPos); +			TrimAndSetSelection(wordSelectAnchorStartPos, wordSelectAnchorEndPos);  	}  } diff --git a/src/Editor.h b/src/Editor.h index c33f5b5f1..f8ab19d9e 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -493,6 +493,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	bool PointInSelection(Point pt);  	bool PointInSelMargin(Point pt);  	Window::Cursor GetMarginCursor(Point pt); +	void TrimAndSetSelection(int currentPos_, int anchor_);  	void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);  	void WordSelection(int pos);  	void DwellEnd(bool mouseMoved); | 
