qsantos / ViHN

Vim for Hacker News

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncollapsing grandparent makes children of collapsed comment visible

qsantos opened this issue · comments

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

To reproduce:

  • locate a grandchild comment C that has children of its own
  • collapse comment C
  • collapse comment C's grandparent
  • uncollapse comment C's grandparents

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

Example

image

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

Reproduction:

Hacker.News.bug.mp4

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);
       }
     }
   }