about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/local/container.nim3
-rw-r--r--src/local/pager.nim6
2 files changed, 9 insertions, 0 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index 9dc9d552..805c1b80 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -142,6 +142,9 @@ type
     numLines*: int
     replace*: Container
     replaceBackup*: Container # for redirection; when set, we get discarded
+    # if we are referenced by another container, replaceRef is set so that we
+    # can clear ourselves on discard
+    replaceRef*: Container
     code*: int # note: this is not the status code, but the ConnectErrorCode.
     errorMessage*: string
     retry*: seq[URL]
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 6430416f..e150507c 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -936,6 +936,10 @@ proc deleteContainer(pager: Pager; container, setTarget: Container) =
   if container.sourcepair != nil:
     container.sourcepair.sourcepair = nil
     container.sourcepair = nil
+  if container.replaceRef != nil:
+    container.replaceRef.replace = nil
+    container.replaceRef.replaceBackup = nil
+    container.replaceRef = nil
   if container.parent != nil:
     let parent = container.parent
     let n = parent.children.find(container)
@@ -1225,8 +1229,10 @@ proc gotoURL(pager: Pager; request: Request; prevurl = none(URL);
       pager.replace(replace, container)
       if replaceBackup == nil:
         container.replace = replace
+        replace.replaceRef = container
       else:
         container.replaceBackup = replaceBackup
+        replaceBackup.replaceRef = container
       container.copyCursorPos(replace)
     else:
       pager.addContainer(container)