Skip to content

Commit

Permalink
textcore: close open files logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoreilly committed Mar 8, 2025
1 parent e02c025 commit 5f8ef1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion code/cmd/cogentcode/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
// we must load the settings before initializing the console
errors.Log(core.LoadAllSettings())

// InitConsole(lfnm)
InitConsole(lfnm)

var path string
var proj string
Expand Down
6 changes: 4 additions & 2 deletions code/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ func (cv *Code) CloseOpenFiles(fnames []string) {
for _, fnm := range fnames {
fi, err := os.Stat(fnm)
if errors.Log(err) != nil {
cv.CloseOpenFile(fnm) // try anyway
continue
}
if !fi.IsDir() {
Expand All @@ -583,10 +584,11 @@ func (cv *Code) CloseOpenFile(fname string) {
}
textcore.Close(cv.Scene, ln, func(canceled bool) {
if canceled {
cv.SetStatus(fmt.Sprintf("File %q NOT closed: recommended as file name changed!", fname))
cv.SetStatus(fmt.Sprintf("File %q NOT closed", fname))
return
}
cv.SetStatus(fmt.Sprintf("File %q closed due to file name change", fname))
cv.SetStatus(fmt.Sprintf("File %q closed", fname))
cv.OpenFiles.DeleteByKey(fname)
})
}

Expand Down

0 comments on commit 5f8ef1a

Please # to comment.