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:
+12
-3
@@ -4,6 +4,7 @@ import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"gioui.org/app"
|
||||
@@ -40,10 +41,18 @@ func run(w *app.Window) error {
|
||||
rootDir := flag.String("root", startpath, "root directory for the filesystem")
|
||||
flag.Parse()
|
||||
|
||||
fs := real.NewRealFileSystem(*rootDir)
|
||||
log.Printf("using filesystem at %s", fs.WorkingDir)
|
||||
// Initialize the real filesystem rooted at the system root "/"
|
||||
// so that the browser can navigate the entire system.
|
||||
fs := real.NewRealFileSystem("/")
|
||||
|
||||
// Get the absolute path of the startup directory
|
||||
startAbs, err := filepath.Abs(*rootDir)
|
||||
if err != nil {
|
||||
startAbs = *rootDir
|
||||
}
|
||||
log.Printf("using filesystem at / (startup directory: %s)", startAbs)
|
||||
|
||||
logic := editor.NewLogic(fs)
|
||||
logic := editor.NewLogic(fs, startAbs)
|
||||
renderer := ui.New(ui.Theme{FontSize: 14}, shaper, logic.State())
|
||||
var mu sync.Mutex
|
||||
var elems []ui.Element
|
||||
|
||||
Reference in New Issue
Block a user