From 61cc2d1df164f26d0aae65621827fac21a3acdef Mon Sep 17 00:00:00 2001 From: surdeus Date: Fri, 6 Oct 2023 11:38:52 +0300 Subject: [PATCH] Fixed the Go("-") behaviour when no history is defined making it go to the root. --- tg/context.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tg/context.go b/tg/context.go index 66845b9..d2efdab 100644 --- a/tg/context.go +++ b/tg/context.go @@ -178,9 +178,13 @@ func (c *Context) Go(pth Path, args ...any) { var back bool if pth == "-" { ln := len(c.pathHistory) - pth = c.pathHistory[ln-2] - c.pathHistory = c.pathHistory[:ln-1] - back = true + if ln <= 1 { + pth = "/" + } else { + pth = c.pathHistory[ln-2] + c.pathHistory = c.pathHistory[:ln-1] + back = true + } } // Getting the screen and changing to // then executing its widget.