Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/wtf_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type WtfApp struct {
pages *tview.Pages
validator *ModuleValidator
widgets []wtf.Wtfable
configWatcher *watcher.Watcher

// The redrawChan channel is used to allow modules to signal back to the main loop that
// the screen needs to be explicitly redrawn, instead of waiting for tcell to redraw
Expand Down Expand Up @@ -136,6 +137,9 @@ func (wtfApp *WtfApp) Start() {
// Stop kills all the currently-running widgets in this app
func (wtfApp *WtfApp) Stop() {
wtfApp.stopAllWidgets()
if wtfApp.configWatcher != nil {
wtfApp.configWatcher.Close()
}
close(wtfApp.redrawChan)
}

Expand Down Expand Up @@ -203,7 +207,8 @@ func (wtfApp *WtfApp) scheduleWidgets() {
}

func (wtfApp *WtfApp) watchForConfigChanges() {
watch := watcher.New()
wtfApp.configWatcher = watcher.New()
watch := wtfApp.configWatcher
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The local variable 'watch' is unnecessary since you can use 'wtfApp.configWatcher' directly throughout the function. This reduces code complexity and eliminates the need for the alias.

Copilot uses AI. Check for mistakes.


// Notify write events
watch.FilterOps(watcher.Write)
Expand Down
7 changes: 5 additions & 2 deletions modules/textfile/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type Widget struct {
view.MultiSourceWidget
view.TextWidget

settings *Settings
settings *Settings
fileWatcher *watcher.Watcher
}

// NewWidget creates a new instance of a widget
Expand Down Expand Up @@ -128,7 +129,8 @@ func (widget *Widget) plainText() string {
}

func (widget *Widget) watchForFileChanges() {
watch := watcher.New()
widget.fileWatcher = watcher.New()
watch := widget.fileWatcher
Copy link

Copilot AI Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The local variable 'watch' is unnecessary since you can use 'widget.fileWatcher' directly throughout the function. This reduces code complexity and eliminates the need for the alias.

Copilot uses AI. Check for mistakes.

watch.FilterOps(watcher.Write)

go func() {
Expand All @@ -143,6 +145,7 @@ func (widget *Widget) watchForFileChanges() {
return
case quit := <-widget.QuitChan():
if quit {
watch.Close()
return
}
}
Expand Down
Loading