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] line value outside range and virtual text being duplicated (probably due to yarn workspaces) #74

Closed Gelio closed 2 years ago

Gelio commented 3 years ago

Issues

Plugin Version

Neovim Version

Neovim Version

v0.6.0-dev+235-ga422f2136

Branch

master

Actual behavior

I am using yarn workspaces and have multiple package.json open at the same time.

I don't know exactly when this happens, but after a while when I have opened a package.json that uses another workspace, I get errors when opening package.jsons:

E5108: Error executing lua ...tart/package-info.nvim/lua/package-info/modules/core.lua:183: line value outside range

and the virtual text that contains package versions is often duplicated:

2021-09-14_13-30

The right package.json does not contain any workspace:* packages.

Expected behavior

The versions are shown only once and there are no errors in :messages

Steps to reproduce

Part of one package.json:

{
  "dependencies": {
    "@cloud/unified": "workspace:*",
    "@graphile-contrib/pg-simplify-inflector": "6.1.0",
    "fastify": "3.14.2",
    "graphile-build": "4.11.0",
    "graphile-build-pg": "4.11.2",
    "graphile-utils": "4.11.2",
    "graphql": "14.7.0",
    "graphql-config": "3.2.0",
    "pg": "8.5.1",
    "pg-native": "3.0.0",
    "postgraphile": "4.11.0"
  },
  "devDependencies": {
    "@types/pg": "7.14.11",
    "nodemon": "2.0.12",
    "npm-run-all": "4.1.5"
  }

Part of another package.json:

{
  "dependencies": {
    "fastify": "3.14.2",
    "fastify-cookie": "5.3.0",
    "isomorphic-unfetch": "3.1.0",
    "pg": "8.5.1",
    "pg-native": "3.0.0",
    "wkx": "0.5.0"
  },
  "devDependencies": {
    "ts-node": "9.1.1"
  }
}

Open both of them side by side. Run :e multiple times on the 2nd package.json.

Package info config

The setup config is empty: https://github.com/Gelio/ubuntu-dotfiles/blob/89861fb0ee589337a7343dbb759b88f3b0772b96/install/neovim/stowed/.config/nvim/lua/plugins.lua#L532

Other information

No response

Help

No, sorry.

Implementation help

No response

vuki656 commented 3 years ago

Interesting. I didn't do much testing with yarn workspaces. Will take a closer look. Thanks for opening an issue.

vuki656 commented 3 years ago

Note to self: this is likely happening because we are keeping only one package.json bufnr in the state. In this case, one is being overridden by the other and it's used for both buffers.

Check when and how its saved

punk-dev-robot commented 2 years ago

same problem here, also using yarn workspaces

jwickers commented 2 years ago

I had this bug whenever going from one package.json to another, so i figured this came from the buffer mismatch and got it to work for me with this little change in core.lua

M.show = function(options)
    if not M.__is_valid_package_json() then
        return
    end

    -- FIX with this
    M.__reload()

    ...
}