Fix directory navigation and path initialization

- Initialize browser path to the actual startup directory instead of '/'
- Improve '..' navigation to be relative to the filesystem root
- Fix path duplication issues by avoiding redundant absolute path joining
This commit is contained in:
gmp
2026-06-05 13:43:27 -04:00
parent 80c2dfd743
commit beae5fc026
4 changed files with 42 additions and 15 deletions
+7 -3
View File
@@ -66,7 +66,7 @@ type Logic struct {
}
// NewLogic creates a new Logic instance, accepting an optional mockFS.
func NewLogic(mfs pool.FileSystem) *Logic {
func NewLogic(mfs pool.FileSystem, startPath ...string) *Logic {
state := NewState()
TheState = state
@@ -81,8 +81,12 @@ func NewLogic(mfs pool.FileSystem) *Logic {
wp := pool.NewWorkerPool(4)
wp.Start()
// Set browser initial path to mock root
state.Browser.CurrentPath = "/"
// Set browser initial path
path := "/"
if len(startPath) > 0 {
path = startPath[0]
}
state.Browser.CurrentPath = path
bm, _ := browser.NewBrowserManager(&state.Browser, wp, mockFS)
TheLogic = &Logic{