diff options
-rw-r--r-- | doc/config.md | 6 | ||||
-rw-r--r-- | src/display/pager.nim | 8 |
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: |