mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-30 07:30:13 +03:00
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".
This commit is contained in:
parent
fd41e70cff
commit
7bcc1ce659
1 changed files with 4 additions and 4 deletions
|
@ -990,8 +990,8 @@ func (c *commandeer) newWatcher(port int) error {
|
||||||
|
|
||||||
// It is probably more confusing than useful
|
// It is probably more confusing than useful
|
||||||
// to navigate to a new URL on RENAME etc.
|
// to navigate to a new URL on RENAME etc.
|
||||||
// so for now we use the WRITE event only.
|
// so for now we use the WRITE and CREATE events only.
|
||||||
name := pickOneWritePath(dynamicEvents)
|
name := pickOneWriteOrCreatePath(dynamicEvents)
|
||||||
|
|
||||||
if name != "" {
|
if name != "" {
|
||||||
p = Hugo.GetContentPage(name)
|
p = Hugo.GetContentPage(name)
|
||||||
|
@ -1027,11 +1027,11 @@ func (c *commandeer) newWatcher(port int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pickOneWritePath(events []fsnotify.Event) string {
|
func pickOneWriteOrCreatePath(events []fsnotify.Event) string {
|
||||||
name := ""
|
name := ""
|
||||||
|
|
||||||
for _, ev := range events {
|
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
|
name = ev.Name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue