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

[BUG] Error when key contained in dependencies and devDependencies #148

Open
3 tasks done
LandonSchropp opened this issue Jan 3, 2024 · 2 comments
Open
3 tasks done
Labels
🐛 Bug Something isn't working

Comments

@LandonSchropp
Copy link

Issues

  • I have checked existing issues and there are no issues with the same problem.

Plugin Version

  • I am using the latest version of the plugin

Neovim Version

  • I am using the 0.6 neovim version or later

Neovim Version

v0.9.4

Branch

master

Actual behavior

I'm running into an issue when switching to a tab an invalid package.json that contains a duplicate key in dependencies and devDependencies.

E5108: Error executing lua: ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:143: Error executing lua: ...al/share/nvim/lazy/mi
ni.bufremove/lua/mini/bufremove.lua:152: BufEnter Autocommands for "package.json": Vim(lua):E5108: Error executing lua vim/shared.lua:0: k
ey found in more than one map: @types/react
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'tbl_extend'
        .../nvim/lazy/package-info.nvim/lua/package-info/parser.lua:12: in function 'parse_buffer'
        ...re/nvim/lazy/package-info.nvim/lua/package-info/core.lua:52: in function 'load_plugin'
        [string ":lua"]:1: in main chunk
        [C]: in function 'nvim_win_set_buf'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:152: in function <...al/share/nvim/lazy/mini.bufremove/lua/mini/bufrem
ove.lua:143>
        [C]: in function 'nvim_win_call'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:143: in function <...al/share/nvim/lazy/mini.bufremove/lua/mini/bufrem
ove.lua:133>
        vim/shared.lua: in function 'tbl_map'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:119: in function 'unshow'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:216: in function 'delete'
        /Users/landon/.config/nvim/lua/astronvim/utils/buffer.lua:158: in function 'close'
        /Users/landon/.config/nvim/lua/astronvim/mappings.lua:51: in function </Users/landon/.config/nvim/lua/astronvim/mappings.lua:51>
stack traceback:
        [C]: in function 'nvim_win_set_buf'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:152: in function <...al/share/nvim/lazy/mini.bufremove/lua/mini/bufrem
ove.lua:143>
        [C]: in function 'nvim_win_call'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:143: in function <...al/share/nvim/lazy/mini.bufremove/lua/mini/bufrem
ove.lua:133>
        vim/shared.lua: in function 'tbl_map'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:119: in function 'unshow'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:216: in function 'delete'
        /Users/landon/.config/nvim/lua/astronvim/utils/buffer.lua:158: in function 'close'
        /Users/landon/.config/nvim/lua/astronvim/mappings.lua:51: in function </Users/landon/.config/nvim/lua/astronvim/mappings.lua:51>
stack traceback:
        [C]: in function 'nvim_win_call'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:143: in function <...al/share/nvim/lazy/mini.bufremove/lua/mini/bufrem
ove.lua:133>
        vim/shared.lua: in function 'tbl_map'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:119: in function 'unshow'
        ...al/share/nvim/lazy/mini.bufremove/lua/mini/bufremove.lua:216: in function 'delete'
        /Users/landon/.config/nvim/lua/astronvim/utils/buffer.lua:158: in function 'close'
        /Users/landon/.config/nvim/lua/astronvim/mappings.lua:51: in function </Users/landon/.config/nvim/lua/astronvim/mappings.lua:51>

Expected behavior

Even though the package is invalid, I wouldn't expect the plugin to product an error.

Steps to reproduce

  1. Add the following package.json:

    {
      "dependencies": {
        "@types/react": "^18.2.45"
      },
      "devDependencies": {
        "@types/react": "^18"
      }
    }
  2. Open the package.json buffer.

  3. Open a second buffer with a different file.

  4. Switch back to the first buffer.

Package info config

I'm using the AstroCommunity TypeScript pack, which this plugin is included in.

Other information

No response

Help

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

Implementation help

If you let me know where the issue is, I can fix it. 🙂

@LandonSchropp LandonSchropp added the 🐛 Bug Something isn't working label Jan 3, 2024
@vuki656
Copy link
Owner

vuki656 commented Jan 11, 2024

Hey, this indeed shouldn't throw.

I'm currently on vacation till the end of month and can take a look after that.

If you are up for it, try to fix it.

I'm quite sure the problem is here as table extend is set to error if there are duplicate keys.

Not really sure what would be the best way to handle this. Maybe show a notification to a user that package json is invalid if there are multiple same name deps? What do you think?

@LandonSchropp
Copy link
Author

No worries on the timeline—I hope you're enjoying your vacation and not spending too much time on GitHub. 😉

I'm a bit swamped myself right now, so I'm not sure if I'll be able to jump in on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants