TextSegmentCollection - unexpected behaviour when replacing text
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu tại ICSharpCode.AvalonEdit/Document/TextSegmentCollection.cs, ở ReplaceText, đặc biệt là các dòng được liên kết, và xem xét lại hành vi của TextSegment.OnSegmentChanged được mô tả trong discussion #327. Tái hiện sự không nhất quán của collection TextMarker trong quá trình thay thế. Hoàn tất khi các callback không còn quan sát segment trong trạng thái trung gian của collection và hành vi thay thế hiện tại vẫn được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I've come across an issue which I suspect is caused by the internal implementation of TextSegmentCollection.ReplaceText, specifically this section
A segment gets removed from the collection, then manipulated, then re-added to the collection.
If there is any logic reacting to the in-between manipulation, it may behave unexpectedly, since the segment is not a member of the collection (at that time).
My problem were Segments (specifically TextMarkers) which got replaced in their entirety, but would claim not to be members of their corresponding collection during a TextSegment.OnSegmentChanged invocation, only to "magically" reappear during later calls (specifically redraws). See https://github.com/icsharpcode/AvalonEdit/discussions/327
There may be some hacky ways to work around the problem (sadly there are no "added/removed" triggers for the segment collection.. and it's sealed...). One could post some handler via Dispatcher to "recheck" a segment... but that's... messy.
A clean solution to my mind would be adding BeginChange() / EndChange() methods to TextSegment (similar to what exists for TextDocument) which suppress all OnSegmentChanged invocations and rework the ReplaceText method to use those methods:
...
segment.BeginChange();
RemoveSegment(segment);
segment.StartOffset = offset + change.RemovalLength;
segment.Length = Math.Max(0, remainingLength);
AddSegment(segment);
segment.EndChange();
...
That would defer any OnSegmentChanged invocation until the segment is once again in an expected state.
- Ngôn ngữ chính
- C#
- Star
- 2.1k
- Fork
- 496
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của icsharpcode/AvalonEdit
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
icsharpcode/AvalonEdit#454 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
icsharpcode/AvalonEdit#449 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
icsharpcode/AvalonEdit#446 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 28/100
icsharpcode/AvalonEdit#445 · 1 bình luận ·
-
Context menu ApplicationCommands.Cut still enabled when IsReadOnly = trueCó thể đã có người làm @JyslaFancy đã nhận 162 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
icsharpcode/AvalonEdit#444 ·
Tất cả issue của icsharpcode/AvalonEdit
Issue tương tự
-
type:task ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
elsa-workflows/elsa-foundation#5253 ·
Maintainer thường phản hồi trong vòng 1 ngày