reload modified files when loading cache

Related #92
This commit is contained in:
Gokcehan committed 2018-06-07 22:49:53 +03:00
1 parent 4846a74320
commit 7acc85f81c
2 files changed
+23 -4

No files matched your search

+13 -2
View File
@@ -370,7 +370,7 @@ func (nav *nav) preview() {
reader = f
}
reg := &reg{path: curr.path}
reg := &reg{loadTime: time.Now(), path: curr.path}
buf := bufio.NewScanner(reader)
@@ -396,10 +396,21 @@ func (nav *nav) loadReg(ui *ui, path string) *reg {
r, ok := nav.regCache[path]
if !ok {
go nav.preview()
r := &reg{path: path, lines: []string{"\033[1mloading...\033[0m"}}
r := &reg{loading: true, path: path}
nav.regCache[path] = r
return r
}
s, err := os.Stat(r.path)
if err != nil {
return r
}
if s.ModTime().After(r.loadTime) {
r.loadTime = time.Now()
go nav.preview()
}
return r
}