Skip to content

Commit a59f8ae

Browse files
committed
Merge pull request #42 from nippur72/duobleclick-word
Fix #37: move caret to start or end of selection in word-selection or line-selection modes
2 parents 6f76dd9 + fd7155f commit a59f8ae

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,11 @@ void ExtendSelectionToMouse(MouseEventArgs e)
644644
textArea.Selection = Selection.Create(textArea,
645645
Math.Min(newWord.Offset, startWord.Offset),
646646
Math.Max(newWord.EndOffset, startWord.EndOffset));
647-
// Set caret offset, but limit the caret to stay inside the selection.
648-
// in whole-word selection, it's otherwise possible that we get the caret outside the
649-
// selection - but the TextArea doesn't like that and will reset the selection, causing
650-
// flickering.
651-
SetCaretOffsetToMousePosition(e, textArea.Selection.SurroundingSegment);
647+
// moves caret to start or end of selection
648+
if( newWord.Offset < startWord.Offset)
649+
textArea.Caret.Offset = newWord.Offset;
650+
else
651+
textArea.Caret.Offset = Math.Max(newWord.EndOffset, startWord.EndOffset);
652652
}
653653
}
654654
textArea.Caret.BringCaretToView(5.0);

0 commit comments

Comments
 (0)