diff options
author | Vasiliy Solovey <iam@miltador.pro> | 2017-07-08 09:06:38 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-07-08 09:37:24 +0200 |
commit | 7bcc1ce659710f2220b400ce3b76e50d2e48b241 (patch) | |
tree | 8e27ac2e2e94be23ea5657ee41bcb9b66aba460a /commands | |
parent | fd41e70cff731c363ad78fa5fe7c281f4f5b1162 (diff) |
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".
Diffstat (limited to 'commands')
-rw-r--r-- | commands/hugo.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index b939ce6e9..3210cdba6 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -990,8 +990,8 @@ func (c *commandeer) newWatcher(port int) error { // 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 @@ func (c *commandeer) newWatcher(port int) error { 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 } } |