about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-16 15:21:53 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-16 15:21:53 +0100
commitcadad89534e46c1465a0b33b6d7c1564afc33a19 (patch)
treef47cba1ba132df9a7a023414e911bfc06160bc32
parent1f701c31d47f48d86e825f291004a2df8541bdf2 (diff)
downloadchawan-cadad89534e46c1465a0b33b6d7c1564afc33a19.tar.gz
discardTree only kills child buffers, fix discardBuffer
-rw-r--r--doc/config.md6
-rw-r--r--src/display/pager.nim8
2 files changed, 8 insertions, 6 deletions
diff --git a/doc/config.md b/doc/config.md
index d64d0d59..0570c065 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -510,9 +510,9 @@ the prompt. If this string ends with a newline
 
 <tr>
 <td>`pager.discardBuffer()`</td>
-<td>Discard the current buffer, and move back to its parent. If the current
-buffer is a root buffer (i.e. it has no parent), move to the first child
-buffer instead.</td>
+<td>Discard the current buffer, and move back to its previous sibling buffer,
+or if that doesn't exist, to its parent. If the current buffer is a root buffer
+(i.e. it has no parent), move to the next sibling buffer instead.</td>
 </tr>
 
 <tr>
diff --git a/src/display/pager.nim b/src/display/pager.nim
index 9bce0e48..98b5da25 100644
--- a/src/display/pager.nim
+++ b/src/display/pager.nim
@@ -427,7 +427,10 @@ proc deleteContainer(pager: Pager, container: Container) =
       parent.children.insert(child, n + 1)
     parent.children.delete(n)
     if container == pager.container:
-      pager.setContainer(parent)
+      if n == 0:
+        pager.setContainer(parent)
+      else:
+        pager.setContainer(parent.children[n - 1])
   elif container.children.len > 0:
     let parent = container.children[0]
     parent.parent = nil
@@ -458,9 +461,8 @@ proc discardTree(pager: Pager, container = none(Container)) {.jsfunc.} =
   if container != nil:
     for c in container.all_children:
       pager.deleteContainer(c)
-    pager.discardBuffer(some(container))
   else:
-    pager.alert("Cannot discard last buffer!")
+    pager.alert("Buffer has no children!")
 
 proc toggleSource*(pager: Pager) {.jsfunc.} =
   if pager.container.sourcepair != nil: