vuki656 / package-info.nvim

✍️ All the npm/yarn/pnpm commands I don't want to type
GNU General Public License v3.0
480 stars 27 forks source link

[BUG] Buffer reload triggers show again when autostart is enabled #90

Closed mtoohey31 closed 2 years ago

mtoohey31 commented 2 years ago

Issues

Plugin Version

Neovim Version

Neovim Version

v0.5.1

Branch

master

Actual behavior

The :e command here triggers the autocommand here when autostart is enabled leading to the buffer being reloaded multiple times.

Expected behavior

Show should not be triggered again if it is already running.

Steps to reproduce

First, enable autostart. If you throw print statements at the start of the show command (maybe with something like os.clock() appeneded so you can see changes between multiple occurrences), you'll see that it runs multiple times after entering a buffer.

Package info config

require("package-info").setup()

Other information

No response

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

There's probably multiple ways to do this, not sure what's best, we could maybe set some kind of global variable and check if it's set before running the show command when entering a buffer. If I swap :e to :noa e (which disables the trigger of autocommands), the show command is only run once, but this prevents other plugins that rely on autocommands from working, so that's not a feasible solution.

mtoohey31 commented 2 years ago

Actually the fix may be simpler than I thought, is there any need to reload the buffer here if we're just showing the status? Will npm ever update the package.json if we're just checking the outdated dependencies?

mtoohey31 commented 2 years ago

I'm testing the removal of the line above now, if I don't run into any bugs do you want me to open a pull request?

vuki656 commented 2 years ago

I'm testing the removal of the line above now, if I don't run into any bugs do you want me to open a pull request?

Sure!