saros-project / saros

Open Source IDE plugin for distributed collaborative software development
https://www.saros-project.org
GNU General Public License v2.0
158 stars 52 forks source link

Prune annotation store #1127

Closed tobous closed 3 years ago

tobous commented 3 years ago

Adjusts the annotations handling to always prune annotations that have a zero width after a text deletion. This is necessary as such annotations are not always invalidated by IntelliJ IDEA automatically (see #873).

Also adjusts the annotation store to always dispose/tear down any highlighters still present when removing an annotation. This ensures that existing range highlighters will always be completely removed from their editor when an annotation is removed from the annotation store.

I would suggest reviewing this PR commit by commit. The different commit messages give more details on their specific contents.

Commits

[FIX][I] Ensure removed annotations are always correctly torn down
Adjusts the annotation logic to always properly dispose all range highlighters when an annotation is removed from the annotation store. Previously, it was the responsibility of the caller to do so. Including the teardown in the removal ensures that all range highlighter are properly removed. Removes the manual tear down calls now no longer necessary. Adjusts AnnotationManagerTest for removing invalidated annotations to also mock the removal call for the caret annotation. This is now necessary as the new logic ensures that the caret annotation is correctly removed when the rest of the selection annotation becomes invalid.
[FIX][I] #873 Prune annotation store after text removal
Adjusts the logic to always prune the annotation store when text was removed from a document that is open in an editor. This is necessary to remove zero-width annotations not automatically invalidated by IntelliJ IDEA. This is the case when an annotation is removed character by character instead of removing the entire range at once. In such cases the annotation is preserved instead of being invalidated. Such an annotation is not invalidated by IntelliJ IDEA as it could be configured to be "greedy", meaning it would extend to any new additions made at its edges. This would allow a zero-width annotation to re-grow to a visible size. Resolves #873.
[REFACTOR][I] Rename document modification handlers
Renames the document modification handler implementations to better match their purposes. Also adjusts the documentation of the LocalDocumentModificationAnnotationUpdater to match its new purpose.
tobous commented 3 years ago

Rebased onto current master only fixing minor merge conflicts.

tobous commented 3 years ago

Replaced removeIf lambda call with an iterator for loop.