Skip to content

Commit 417a3ab

Browse files
committed
fix AssociatedPathName
1 parent 2402892 commit 417a3ab

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

internal/watcher/pattern.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ func (p *pattern) allowReload(event *Event) bool {
9999
return false
100100
}
101101

102-
return p.isValidPattern(event)
102+
// some editors create temporary files and never actually modify the original file
103+
// so we need to also check Event.AssociatedPathName
104+
// see https://github.com/php/frankenphp/issues/1375
105+
return p.isValidPattern(event.PathName) || p.isValidPattern(event.AssociatedPathName)
103106
}
104107

105108
func (p *pattern) handle(event *Event) {
@@ -135,13 +138,9 @@ func isValidPathType(event *Event) bool {
135138
return event.PathType <= PathTypeHardLink
136139
}
137140

138-
// some editors create temporary files and never actually modify the original file
139-
// so we need to also check Event.AssociatedPathName
140-
// see https://github.com/php/frankenphp/issues/1375
141-
func (p *pattern) isValidPattern(event *Event) bool {
142-
fileName := event.AssociatedPathName
141+
func (p *pattern) isValidPattern(fileName string) bool {
143142
if fileName == "" {
144-
fileName = event.PathName
143+
return false
145144
}
146145

147146
// first we remove the dir from the file name

0 commit comments

Comments
 (0)