commit 1a2bb12

delthas  ·  2023-11-17 00:31:02 +0000 UTC
parent decbe3d
Fix calling highlight with HERE=1 on different networks
1 files changed,  +6, -4
M app.go
M app.go
+6, -4
 1@@ -956,7 +956,9 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
 2 		}
 3 		app.win.AddLine(netID, buffer, line)
 4 		if line.Notify == ui.NotifyHighlight {
 5-			app.notifyHighlight(buffer, ev.User, line.Body.String())
 6+			curNetID, curBuffer := app.win.CurrentBuffer()
 7+			current := curNetID == netID && curBuffer == buffer
 8+			app.notifyHighlight(buffer, ev.User, line.Body.String(), current)
 9 		}
10 		if !s.IsChannel(msg.Params[0]) && !s.IsMe(ev.User) {
11 			app.lastQuery = msg.Prefix.Name
12@@ -1150,7 +1152,7 @@ func (app *App) isHighlight(s *irc.Session, content string) bool {
13 
14 // notifyHighlight executes the script at "on-highlight-path" according to the given
15 // message context.
16-func (app *App) notifyHighlight(buffer, nick, content string) {
17+func (app *App) notifyHighlight(buffer, nick, content string, current bool) {
18 	if app.cfg.OnHighlightBeep {
19 		app.win.Beep()
20 	}
21@@ -1173,7 +1175,7 @@ func (app *App) notifyHighlight(buffer, nick, content string) {
22 		path = defaultHighlightPath
23 	}
24 
25-	netID, curBuffer := app.win.CurrentBuffer()
26+	netID, _ := app.win.CurrentBuffer()
27 	if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
28 		// only error out if the user specified a highlight path
29 		// if default path unreachable, simple bail
30@@ -1189,7 +1191,7 @@ func (app *App) notifyHighlight(buffer, nick, content string) {
31 		return
32 	}
33 	here := "0"
34-	if buffer == curBuffer { // TODO also check netID
35+	if current {
36 		here = "1"
37 	}
38 	cmd := exec.Command(path)