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

plugin treeview: respect user setting of disabling context menu #1551

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SwissalpS
Copy link
Contributor

I've been working on a project where we disable context menu in project module.

Unfortunately a bunch of plugins including treeview, just load it anyway.

This PR checks first if user has disabled contextmenu before loading it and adding functions to it.

@jgmdev
Copy link
Member

jgmdev commented Jun 29, 2023

It may be better to initialize ContextMenu to nil and move all the initialization and menu items registration into a coroutine using core.add_thread() that performs the config.plugins.contextmenu availability check. This way you properly ensure the plugin is really disabled after everything is loaded up preventing possible issues.

@SwissalpS
Copy link
Contributor Author

@jgmdev is this what you meant? If so, I guess I'll do the same in lite-xl/lite-xl-plugins#267

It seems to be working.
However if [settings] plugin is enabled and [contextmenu] is turned on, turning it off via project module is useless as [settings] loads [contextmenu] anyway.

In our case this is tolerable, we can live without [settings] and manage config, style etc. in project module.
Managing project module is a lot easier than having to maintain a separate portable build only for a single project.

@jgmdev
Copy link
Member

jgmdev commented Jul 3, 2023

@jgmdev is this what you meant? If so, I guess I'll do the same in lite-xl/lite-xl-plugins#267

exactly

It seems to be working. However if [settings] plugin is enabled and [contextmenu] is turned on, turning it off via project module is useless as [settings] loads [contextmenu] anyway.

Maybe this change could fix the issue, haven't tested it:

diff --git a/data/plugins/settings.lua b/data/plugins/settings.lua
index cc29090f..c0c4dcd5 100644
--- a/data/plugins/settings.lua
+++ b/data/plugins/settings.lua
@@ -1543,6 +1543,9 @@ function Settings:load_plugin_settings()
           settings.config.enabled_plugins
           and
           settings.config.enabled_plugins[plugin]
+          and
+          --ensure plugin is not disabled on user or project module
+          config.plugins[plugin] ~= false
         )
       then
         enabled = true
@@ -1877,7 +1880,7 @@ function core.run()
   -- load plugins disabled by default and enabled by user
   if settings.config.enabled_plugins then
     for name, _ in pairs(settings.config.enabled_plugins) do
-      if not config.plugins[name] then
+      if config.plugins[name] == nil then
         require("plugins." .. name)
       end
     end

jgmdev added a commit to pragtical/pragtical that referenced this pull request Jul 4, 2023
…-xl/lite-xl#1551

Prevents the automatic loading of plugins disabled on the user or
project lua modules by the settings ui.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants