From 3f12697be244a2162a3ac684f6d96105f75073a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Du=C5=9Bko?= Date: Fri, 22 Dec 2023 19:54:20 +0100 Subject: [PATCH 1/5] Fix scrolling by mouse selection --- src/AvaloniaEdit/Editing/SelectionMouseHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs index 9b68efd8..ed5d76f1 100644 --- a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs +++ b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs @@ -702,7 +702,7 @@ private void ExtendSelectionToMouse(PointerEventArgs e) TextArea.Caret.Offset = newWord.Offset < _startWord.Offset ? newWord.Offset : Math.Max(newWord.EndOffset, _startWord.EndOffset); } } - TextArea.Caret.BringCaretToView(0); + TextArea.Caret.BringCaretToView(5.0); } #endregion From ede962d9eb519237ad5b39612d5258083525a5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Du=C5=9Bko?= Date: Wed, 27 Dec 2023 11:14:04 +0100 Subject: [PATCH 2/5] avaid scroll jumps by setting vercy close to 0 offset (still fixing no scrolling issue) --- src/AvaloniaEdit/Editing/SelectionMouseHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs index ed5d76f1..02512e69 100644 --- a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs +++ b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs @@ -702,7 +702,7 @@ private void ExtendSelectionToMouse(PointerEventArgs e) TextArea.Caret.Offset = newWord.Offset < _startWord.Offset ? newWord.Offset : Math.Max(newWord.EndOffset, _startWord.EndOffset); } } - TextArea.Caret.BringCaretToView(5.0); + TextArea.Caret.BringCaretToView(0.05); } #endregion From b818b430852e6a4e654407be896e3ecf4ea5aeac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Du=C5=9Bko?= Date: Fri, 5 Jan 2024 20:14:26 +0100 Subject: [PATCH 3/5] find next quick fix --- src/AvaloniaEdit/Search/SearchPanel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AvaloniaEdit/Search/SearchPanel.cs b/src/AvaloniaEdit/Search/SearchPanel.cs index c29c2d4d..f3c86b9d 100644 --- a/src/AvaloniaEdit/Search/SearchPanel.cs +++ b/src/AvaloniaEdit/Search/SearchPanel.cs @@ -293,9 +293,9 @@ public void Reactivate() /// /// Moves to the next occurrence in the file. /// - public void FindNext() + public void FindNext(int additionallOffset = 0) { - var result = _renderer.CurrentResults.FindFirstSegmentWithStartAfter(_textArea.Caret.Offset + 1) ?? + var result = _renderer.CurrentResults.FindFirstSegmentWithStartAfter(_textArea.Caret.Offset + 1 + additionallOffset) ?? _renderer.CurrentResults.FirstSegment; if (result != null) { @@ -327,7 +327,7 @@ public void ReplaceNext() { if (!IsReplaceMode) return; - FindNext(); + FindNext(-1); if (!_textArea.Selection.IsEmpty) { _textArea.Selection.ReplaceSelectionWithText(ReplacePattern ?? string.Empty); From 410864103eff0e6a29580079dd75a30c6d452389 Mon Sep 17 00:00:00 2001 From: KrzysztofDusko <69449360+KrzysztofDusko@users.noreply.github.com> Date: Mon, 8 Jan 2024 17:27:18 +0100 Subject: [PATCH 4/5] Update src/AvaloniaEdit/Editing/SelectionMouseHandler.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel PeƱalba --- src/AvaloniaEdit/Editing/SelectionMouseHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs index 02512e69..ed5d76f1 100644 --- a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs +++ b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs @@ -702,7 +702,7 @@ private void ExtendSelectionToMouse(PointerEventArgs e) TextArea.Caret.Offset = newWord.Offset < _startWord.Offset ? newWord.Offset : Math.Max(newWord.EndOffset, _startWord.EndOffset); } } - TextArea.Caret.BringCaretToView(0.05); + TextArea.Caret.BringCaretToView(5.0); } #endregion From 7ca64681132e50aa8e20d9896dd10fe6b67d5de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Du=C5=9Bko?= Date: Mon, 8 Jan 2024 17:30:13 +0100 Subject: [PATCH 5/5] fix for https://github.com/AvaloniaUI/AvaloniaEdit/pull/390/commits/410864103eff0e6a29580079dd75a30c6d452389 --- src/AvaloniaEdit/Editing/SelectionMouseHandler.cs | 2 +- src/AvaloniaEdit/Search/SearchPanel.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs index 02512e69..93bb3425 100644 --- a/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs +++ b/src/AvaloniaEdit/Editing/SelectionMouseHandler.cs @@ -702,7 +702,7 @@ private void ExtendSelectionToMouse(PointerEventArgs e) TextArea.Caret.Offset = newWord.Offset < _startWord.Offset ? newWord.Offset : Math.Max(newWord.EndOffset, _startWord.EndOffset); } } - TextArea.Caret.BringCaretToView(0.05); + TextArea.Caret.BringCaretToView(5); } #endregion diff --git a/src/AvaloniaEdit/Search/SearchPanel.cs b/src/AvaloniaEdit/Search/SearchPanel.cs index f3c86b9d..c29c2d4d 100644 --- a/src/AvaloniaEdit/Search/SearchPanel.cs +++ b/src/AvaloniaEdit/Search/SearchPanel.cs @@ -293,9 +293,9 @@ public void Reactivate() /// /// Moves to the next occurrence in the file. /// - public void FindNext(int additionallOffset = 0) + public void FindNext() { - var result = _renderer.CurrentResults.FindFirstSegmentWithStartAfter(_textArea.Caret.Offset + 1 + additionallOffset) ?? + var result = _renderer.CurrentResults.FindFirstSegmentWithStartAfter(_textArea.Caret.Offset + 1) ?? _renderer.CurrentResults.FirstSegment; if (result != null) { @@ -327,7 +327,7 @@ public void ReplaceNext() { if (!IsReplaceMode) return; - FindNext(-1); + FindNext(); if (!_textArea.Selection.IsEmpty) { _textArea.Selection.ReplaceSelectionWithText(ReplacePattern ?? string.Empty);