aboutsummaryrefslogtreecommitdiffstats
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.nim11
-rw-r--r--src/server/buffer.nim4
3 files changed, 10 insertions, 8 deletions
diff --git a/src/local/container.nim b/src/local/container.nim
index 65ebf6ad..ab69a0ed 100644
--- a/src/local/container.nim
+++ b/src/local/container.nim
@@ -1484,7 +1484,8 @@ proc onload(container: Container; res: int) =
let anchor = container.url.hash.substr(1)
if anchor != "" or container.config.autofocus:
container.requestLines().then(proc(): Promise[GotoAnchorResult] =
- return container.iface.gotoAnchor(anchor, container.config.autofocus)
+ return container.iface.gotoAnchor(anchor, container.config.autofocus,
+ true)
).then(proc(res: GotoAnchorResult) =
if res.found:
container.setCursorXYCenter(res.x, res.y)
diff --git a/src/local/pager.nim b/src/local/pager.nim
index b77c85f4..72945745 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -1932,11 +1932,12 @@ proc gotoURL(pager: Pager; request: Request; prevurl = none(URL);
let container = pager.container
let url = request.url
let anchor = url.hash.substr(1)
- container.iface.gotoAnchor(anchor, false).then(proc(res: GotoAnchorResult) =
- if res.found:
- pager.dupeBuffer(container, url)
- else:
- pager.alert("Anchor " & url.hash & " not found")
+ container.iface.gotoAnchor(anchor, false, false).then(
+ proc(res: GotoAnchorResult) =
+ if res.found:
+ pager.dupeBuffer(container, url)
+ else:
+ pager.alert("Anchor " & url.hash & " not found")
)
return nil
diff --git a/src/server/buffer.nim b/src/server/buffer.nim
index 508bf66a..bb2ab92c 100644
--- a/src/server/buffer.nim
+++ b/src/server/buffer.nim
@@ -714,12 +714,12 @@ proc findAnchor(box: BlockBox; anchor: Element): Offset =
return box.render.offset
return offset(-1, -1)
-proc gotoAnchor*(buffer: Buffer; anchor: string; autofocus: bool):
+proc gotoAnchor*(buffer: Buffer; anchor: string; autofocus, target: bool):
GotoAnchorResult {.proxy.} =
if buffer.document == nil:
return GotoAnchorResult(found: false)
var anchor = buffer.document.findAnchor(anchor)
- if anchor != nil:
+ if target and anchor != nil:
buffer.document.setTarget(anchor)
var focus: ReadLineResult = nil
# Do not use buffer.config.autofocus when we just want to check if the