Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: reload on vim swap file update #1160

Closed
zdenek-crha opened this issue Mar 6, 2020 · 3 comments
Closed

server: reload on vim swap file update #1160

zdenek-crha opened this issue Mar 6, 2020 · 3 comments
Labels
A-Documentation Area: Documentation

Comments

@zdenek-crha
Copy link
Contributor

I am using vim to edit files while mdbook server is running. Every time vim updates it swap file I get page reload.

Swap file updates are happening even without file save, about every 30 seconds if there was some activity in the file. Constant reloads in mdbook serve is quite annoying, especially when editing long page and each reload jumps to the top.

I think mdbook watch will have same issue, but since files are opened from filesystem and there is no websocket connection to trigger page reload on change, it is not as noticeable.

I've looked for ways to pass list of exclude patterns either on command line or through book.toml, but there seems to be no option for that.

Version: mdbook v0.3.5

mdbook serve log

The log is pruned to show only lines with detected file changes for better illustration of rebuild frequency. In reality, every Files changed line is followed by book build and websocket accepting new connection on tcp (page reload).

From list of changed files it can be seen that mdbook updates built data due to swap change about 5x more frequently than actual number of file changes.

12:15:31 (mdbook::cmd::serve): Serving on: http://localhost:3333
12:15:31 (ws): Listening for new connections on [::1]:3001.
12:15:31 (mdbook::cmd::watch): Listening for changes...
12:15:37 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/chapter.md", "/home/user/mdbook/src/.chapter.md.swp"]
12:15:44 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:16:11 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:16:24 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/chapter.md", "/home/user/mdbook/src/.chapter.md.swp"]
12:16:32 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:17:03 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:17:10 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/chapter.md", "/home/user/mdbook/src/.chapter.md.swp"]
12:17:18 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:17:25 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:17:45 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:18:20 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:18:37 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:19:03 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:19:25 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:20:07 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:20:32 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:20:55 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/chapter.md", "/home/user/mdbook/src/.chapter.md.swp"]
12:21:06 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:21:09 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:21:12 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/chapter.md", "/home/user/mdbook/src/.chapter.md.swp"]
12:21:20 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:24:34 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:24:43 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:25:52 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:26:20 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:26:52 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:27:14 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/chapter.md", "/home/user/mdbook/src/.chapter.md.swp"]
12:27:22 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:29:04 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
12:29:12 (mdbook::cmd::serve): Files changed: ["/home/user/mdbook/src/.chapter.md.swp"]
@ehuss
Copy link
Contributor

ehuss commented Mar 7, 2020

You can create a file named .gitignore with *.swp to make it ignore these files.

@zdenek-crha
Copy link
Contributor Author

@ehuss Thanks for tip. I do have *.swp in the globale $HOME/.gitignore file and therefore it did not occur to me that adding it into book directory .gitignore might help.

I'll try to see if I can do documentation update PR sometime this week.

zdenek-crha added a commit to zdenek-crha/mdBook that referenced this issue Mar 28, 2020
The serve and watch commands use .gitignore file in book root directory
to read exclude patterns used when watching for changed files. A
.gitignore from parent directory or user home is not used though.

Add documentation of this behaviour to both commands.
ehuss added a commit that referenced this issue Apr 21, 2020
Mention that .gitignore is used for watch excludes (#1160)
@ehuss ehuss added the A-Documentation Area: Documentation label Apr 21, 2020
@zdenek-crha
Copy link
Contributor Author

The documentation has been updated to make it easier to learn about how excludes work.

Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this issue Aug 30, 2020
The serve and watch commands use .gitignore file in book root directory
to read exclude patterns used when watching for changed files. A
.gitignore from parent directory or user home is not used though.

Add documentation of this behaviour to both commands.
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this issue Aug 30, 2020
Mention that .gitignore is used for watch excludes (rust-lang#1160)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Documentation Area: Documentation
Projects
None yet
Development

No branches or pull requests

2 participants