ref: 7bcc1ce659710f2220b400ce3b76e50d2e48b241
parent: fd41e70cff731c363ad78fa5fe7c281f4f5b1162
author: Vasiliy Solovey <[email protected]>
date: Sat Jul 8 05:06:38 EDT 2017
commands: Navigate to changed on CREATE When working with content from IntelliJ IDE, like WebStorm, every file save is followed by two events: "RENAME" and then "CREATE".
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -990,8 +990,8 @@
// It is probably more confusing than useful
// to navigate to a new URL on RENAME etc.
- // so for now we use the WRITE event only.
- name := pickOneWritePath(dynamicEvents)
+ // so for now we use the WRITE and CREATE events only.
+ name := pickOneWriteOrCreatePath(dynamicEvents)
if name != "" {
p = Hugo.GetContentPage(name)
@@ -1027,11 +1027,11 @@
return nil
}
-func pickOneWritePath(events []fsnotify.Event) string {
+func pickOneWriteOrCreatePath(events []fsnotify.Event) string {
name := ""
for _, ev := range events {
- if ev.Op&fsnotify.Write == fsnotify.Write && len(ev.Name) > len(name) {
+ if (ev.Op&fsnotify.Write == fsnotify.Write || ev.Op&fsnotify.Create == fsnotify.Create) && len(ev.Name) > len(name) {
name = ev.Name
}
}