nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.59k stars 827 forks source link

Extensions: `ext.setup()` is called more than twice #2473

Open hinell opened 1 year ago

hinell commented 1 year ago

Description

https://github.com/nvim-telescope/telescope.nvim/blob/6258d50b09f9ae087317e392efe7c05a7323492d/lua/telescope/_extensions/init.lua#L15-L26

https://github.com/nvim-telescope/telescope.nvim/blob/6258d50b09f9ae087317e392efe7c05a7323492d/lua/telescope/_extensions/init.lua#L61-L67

 ext.setup(extensions._config[k] or {}, require("telescope.config").values) 

The above line. The same call to ext.setup() just a few lines apart. Worse, in first case it's called EVERY time extension is loaded by require('telescope').extensions.EXTENION_NAME.someMethod() without actually being provided any configs that ext.setup() function expects. This may result in unpredicted behavior and overhead. I've discovered this issue while digging up telescope-recent-files extension.

Telescope version / branch / rev

6258d50b09f9ae087317e392efe7c05a7323492d

jamestrew commented 1 year ago

I've looked into this in the past but I think this is intended behavior. https://github.com/nvim-telescope/telescope.nvim/pull/1795

hinell commented 1 year ago

@jamestrew What do you mean intended? It may easily overwrite configs in extensions and wreack a havoc. Where is this expected to be used really?

jamestrew commented 1 year ago

I mean that having ext.setup been called multiple times is on purpose as it prevents more issues than it causes.