qsantos / ViHN

Vim for Hacker News
25 stars 1 forks source link

Uncollapsing grandparent makes children of collapsed comment visible #40

Closed qsantos closed 7 months ago

qsantos commented 7 months ago

This is actually a bug of Hacker News, but should be addressed by ViHN

qsantos commented 7 months ago

To reproduce:

Comment C is still collapsed, as expected. However, rhe children of comment C are visible. They should not be since comment C is collapsed.

qsantos commented 7 months ago

https://news.ycombinator.com/item?id=39498281#39515468 can be used as “comment C”

qsantos commented 7 months ago

The bug was introduced on 2021-09-02:

qsantos commented 7 months ago

Example

image

In the screenshot above, the highlighted comment by letmeinhere is collapsed, but its child by AYoung010 is visible.

qsantos commented 7 months ago

Reproduction:

https://github.com/qsantos/ViHN/assets/8493765/01b4f0c6-b6d6-40ea-b3ac-9bfa5360550b

qsantos commented 7 months ago

Corresponding patch for Hacker News:

diff --git a/hn.js b/hn.js
index 946eda9..a1ae174 100644
--- a/hn.js
+++ b/hn.js
@@ -59,11 +59,10 @@ function kidvis (tr, show) {
         break;
       } else if (!show) {
         setshow(tr, false);
-      } else if (ind(tr) == n) {
+      } else if (!coll || ind(tr) <= n) {
+        n = ind(tr);
         coll = hasClass(tr, 'coll');
         setshow(tr, true);
-      } else if (!coll) {
-        setshow(tr, true);
       }
     }
   }