diff options
author | nyamatongwe <devnull@localhost> | 2012-05-08 22:07:57 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2012-05-08 22:07:57 +1000 |
commit | e3ecdee5158583f43b6bb2cf2b461c81cb9608e3 (patch) | |
tree | c0874fe0acc1e3bea28a310cbbc5b4339fd3ca46 /src/Editor.cxx | |
parent | 5a5b23882ea5f084f591dbe4337eb5b67c23cdb9 (diff) | |
download | scintilla-mirror-e3ecdee5158583f43b6bb2cf2b461c81cb9608e3.tar.gz |
Feature #3520037. Trim current selection when setting a word or
line selection to avoid any doubly selected ranges.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 15 |
1 files changed, 10 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); } } |