You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/05/15 22:00:53 UTC
[GitHub] [netbeans] eirikbakke commented on a change in pull request #2139: NETBEANS-2082: do not scroll to caret after fold collapse, if caret is s off-screen.
eirikbakke commented on a change in pull request #2139:
URL: https://github.com/apache/netbeans/pull/2139#discussion_r426062752
##########
File path: ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java
##########
@@ -260,24 +260,25 @@ public void finishCreation() {
@Override
public void foldHierarchyChanged(FoldHierarchyEvent evt) {
- if (!collapsedFoldEncountered) {
- // Check if any collapsed fold was added or a collapsed/expanded state changed
- for (int i = evt.getAddedFoldCount() - 1; i >= 0; i--) {
- if (evt.getAddedFold(i).isCollapsed()) {
- collapsedFoldEncountered = true;
- break;
- }
+ boolean collapsedAdded = false;
+ boolean changedToCollapsed = false;
+ // Check if any collapsed fold was added or a collapsed/expanded state changed
+ for (int i = evt.getAddedFoldCount() - 1; i >= 0; i--) {
+ if (evt.getAddedFold(i).isCollapsed()) {
+ collapsedAdded = true;
+ break;
}
- if (!collapsedFoldEncountered) {
- for (int i = evt.getFoldStateChangeCount() - 1; i >= 0; i--) {
- FoldStateChange foldStateChange = evt.getFoldStateChange(i);
- if (foldStateChange.isCollapsedChanged() && foldStateChange.getFold().isCollapsed()) {
- collapsedFoldEncountered = true;
- break;
- }
+ }
+ if (!collapsedAdded) {
+ for (int i = evt.getFoldStateChangeCount() - 1; i >= 0; i--) {
+ FoldStateChange foldStateChange = evt.getFoldStateChange(i);
+ if (foldStateChange.isCollapsedChanged() && foldStateChange.getFold().isCollapsed()) {
+ changedToCollapsed = true;
Review comment:
Should this variable perhaps be called "changeToCollapsed" rather than "changedToCollapsed"?
Also, why keep this variable at all--why not just do "collapsedFoldEncountered = true" instead?
##########
File path: ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java
##########
@@ -289,7 +290,9 @@ public void foldHierarchyChanged(FoldHierarchyEvent evt) {
ViewUtils.log(CHANGE_LOG, "CHANGE in FoldViewFactory: <" + // NOI18N
startOffset + "," + endOffset + ">\n"); // NOI18N
}
- comp.putClientProperty("editorcaret.updateRetainsVisibleOnce", Boolean.TRUE);
+ if (collapsedAdded) {
Review comment:
Would be good to add a comment here referencing the bug that is fixed by doing updateRetainsVisibleOnce only in the collapsedAdded case, and why this fixes the bug.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists