Files
loov--lensm/fileui_comments.go
wehub-resource-sync c4536f7e05
CI / test (push) Failing after 1s
CI / macOS amd64 (push) Has been cancelled
CI / macOS arm64 (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:30:31 +08:00

37 lines
1.0 KiB
Go

package main
import (
"fmt"
"os"
"loov.dev/lensm/internal/comments"
)
func (ui *FileUI) loadCommentsForPath(exePath string) {
// Write out anything buffered for the previous binary first.
if err := ui.Comments.Flush(); err != nil {
fmt.Fprintf(os.Stderr, "unable to save comments: %v\n", err)
}
commentsPath := ui.Config.CommentsPath
if commentsPath == "" {
commentsPath = comments.DefaultPath(exePath)
}
store, err := comments.Open(commentsPath, exePath)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to load comments from %q: %v\n", commentsPath, err)
store, _ = comments.Open("", exePath)
}
ui.Comments = store
}
// setBufferedComment records the comment in memory and schedules the
// disk write, so typing doesn't rewrite the sidecar per keystroke.
func (ui *FileUI) setBufferedComment(coord comments.Coord, text string) {
if err := ui.Comments.SetBuffered(coord, text); err != nil {
ui.saveError = "comment not saved: " + err.Error()
fmt.Fprintln(os.Stderr, err)
return
}
ui.scheduleFlush()
}