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

Open path in terminal menu entry visible despite preference set to false #275

Closed
trancexpress opened this issue Dec 18, 2023 · 6 comments · Fixed by #276
Closed

Open path in terminal menu entry visible despite preference set to false #275

trancexpress opened this issue Dec 18, 2023 · 6 comments · Fixed by #276
Labels
Milestone

Comments

@trancexpress
Copy link
Contributor

To reproduce:

  1. Start in a new workspace.
  2. Go to the Bash Editor preference page, Launch, disable the show "Open path in terminal" option.
  3. Restart Eclipse.
  4. Right-click on some resource in the Package Explorer.
  5. Observe the disabled menu entry is visible.

See screen recording:

bash_editor_open_in_terminal.mp4

Additionally it doesn't seem to be possible to set the default for the preference via a -pluginCustomization file (https://eclipse.dev/eclipse/platform-core/documents/user_settings/plugin_customization.html)

@trancexpress
Copy link
Contributor Author

Seems like the property tester that controls the menu entry visibility is not loaded when showing the menu. Its loaded when going in the preference page for Bash Editor, or when clicking the menu entry.

@de-jcup
Copy link
Owner

de-jcup commented Jan 16, 2024

Testing

Without restart

I tested with eclipse 2023-09 + bash editor plugin 2.9.0 (installed by marketplace) and it works as expected when NOT restarting eclipse:

  1. Start in a new workspace.
  2. Go to the Bash Editor preference page, Launch, disable the show "Open path in terminal" option.
  3. Restart Eclipse
  4. Right-click on some resource in the Package Explorer.
  5. Observe the disabled menu entry is NOT visible.

Now with restarting eclipse:

Preference dialog calls

  • Restart eclipse
  • Problems as described, the preference is defined as false but menu entry still visible
  • Entering now preference dialog, open no special dialog, then just close
  • menu entry still visible
  • Entering now bash editor root preference dialog, then just close
  • now menu entry is vanished/no longer visible

Bash editor startup

  • Restart eclipse
  • Problems as described, the preference is defined as false but menu entry still visible
  • Open a test.sh file inside bash editor
  • now menu entry is vanished/no longer visible

Conclusion

Looking into OpenPathInTerminalPropertyTester it uses BashEditorPreferences.getInstance().isOpenPathInTerminalEnabled();
which internally only uses the eclipse preference api:

public boolean isOpenPathInTerminalEnabled() {
return getBooleanPreference(P_OPEN_PATH_IN_TERMINAL_ENABLED);
}

It seems the implementation is correct and that this is more an eclipse problem: As long as there is no plugin interaction (editor, preference pages, etc.) the bash editor preferences seems to be not loaded by eclipse.

Maybe this is related to eclipse-platform/eclipse.platform#523

trancexpress added a commit to trancexpress/eclipse-bash-editor that referenced this issue Jan 16, 2024
This change ensures Eclipse correctly uses the property testers
'isBashFileWithoutExtension' and 'isOpenPathActionEnabled', by setting
the 'forcePluginActivation' property in the respective plugin.xml
entries. This allows Eclipse to load the property tester class prior to
trying to use it - in case the bash editor plug-in was not activated
yet.

Fixes: de-jcup#275
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
@trancexpress
Copy link
Contributor Author

Hi @de-jcup ,

I've debugged a bit, it looks like Eclipse needs the forcePluginActivation property to be set, for the custom property testers in your plug-in to work also prior to activating the plug-in. I've set a PR: #276

The stack trace of interest is e.g.:

        at org.eclipse.core.internal.expressions.Property.setPropertyTester(Property.java:44)
        at org.eclipse.core.internal.expressions.TypeExtensionManager.getProperty(TypeExtensionManager.java:139)
        at org.eclipse.core.expressions.TestExpression.evaluate(TestExpression.java:104)
        at org.eclipse.core.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:54)
        at org.eclipse.core.internal.expressions.AdaptExpression.evaluate(AdaptExpression.java:121)
        at org.eclipse.core.expressions.CompositeExpression.evaluateOr(CompositeExpression.java:68)
        at org.eclipse.core.expressions.OrExpression.evaluate(OrExpression.java:26)
        at org.eclipse.core.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:54)
        at org.eclipse.core.internal.expressions.IterateExpression.evaluate(IterateExpression.java:163)
        at org.eclipse.core.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:54)
        at org.eclipse.core.expressions.WithExpression.evaluate(WithExpression.java:84)
        at org.eclipse.core.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:54)
        at org.eclipse.core.internal.expressions.EnablementExpression.evaluate(EnablementExpression.java:59)
        at org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension.evalEnablementExpression(LaunchShortcutExtension.java:276)
        at org.eclipse.debug.ui.actions.ContextualLaunchAction.isApplicable(ContextualLaunchAction.java:308)
        at org.eclipse.debug.ui.actions.ContextualLaunchAction.fillMenu(ContextualLaunchAction.java:222)
        at org.eclipse.debug.ui.actions.ContextualLaunchAction$1.menuShown(ContextualLaunchAction.java:141)

And in particular org.eclipse.core.internal.expressions.TypeExtensionManager.getProperty(Object, String, String, boolean) receives the flag. Without activating the plug-in, the class of the property tester is not loaded (until the plug-in is activated) and so the property is not evaluated correctly.

See also Eclipse documentation, e.g.: https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_menus.html

Alternatively we can change your plug-in to use the early/eager start-up, i.e. get activated when Eclipse is started. Though I'm not sure this is better.

Best regards,
Simeon

@de-jcup de-jcup added this to the 2.10.0 milestone Jan 17, 2024
@de-jcup de-jcup added the bug label Jan 17, 2024
@trancexpress
Copy link
Contributor Author

Thanks for merging!

@de-jcup
Copy link
Owner

de-jcup commented Jan 17, 2024

@trancexpress : I just released Version 2.9.1 to eclipse marketplace. It contains your changes

@trancexpress
Copy link
Contributor Author

Great, thank you @de-jcup !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants