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

Filtering options are greyed out / disabled except for folding options #53

Closed
uglycoyote opened this issue Jan 30, 2019 · 30 comments

Comments

@uglycoyote
Copy link

commented Jan 30, 2019

I have used this plugin for quite a while and it is great!

But today I tried to use it and strangely when I did Ctrl-Shift-P, the only filtering actions that were in the actions menu were the ones to do with Folding. These are not useful to me, I only use the "include lines" and "exclude lines" actions, but these are for some reason not available.

I can see the options that I want to use under Edit-->Line but they are greyed out, and it is not clear why.

There's nothing too unusual about the text file that I'm trying to use it on, I have tried a few files.

I uninstalled the package and reinstalled using package control, but still have the same problem.

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Feb 9, 2019

Hi, I can't reproduce that. Have you installed other packages that use the same keyboard shortcuts?

@uglycoyote

This comment has been minimized.

Copy link
Author

commented Feb 10, 2019

I'm not sure, but I haven't ever used the keyboard shortcuts. I could understand the hotkeys not working if they were double-mapped, but it would be strange if it greyed out the menu option because of that.

It's working fine on my personal laptop, but on my Windows machine at work it was having the problem.

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Feb 10, 2019

Is your personal laptop also Windows?

@uglycoyote

This comment has been minimized.

Copy link
Author

commented Feb 10, 2019

I have both a personal Macbook and and Windows machine, and Filter Lines plugin seems to run fine on both of those.

So I'm also not sure how to reproduce the problem.

It could be a bug in sublime rather than your plugin perhaps. I filed the bug assuming that your plugin has some specific logic about when to disable certain actions. When I was having the problem, the FilterLines actions related to "folding" were available, and the ones related to including/excluding lines were not, which I took to mean there was some internal logic within the filterlines plugin about when to enable specific actions, and perhaps there was a bug in that logic.

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Feb 10, 2019

I don’t have a Windows computer to test this. Would you check the ST3 console next time you launch it on your work computer?

@uglycoyote

This comment has been minimized.

Copy link
Author

commented Feb 10, 2019

I looked at the ST3 console before and did not see anything that looked related to the problem. I'll check again when I'm back in the office on my work computer. I doubt that the problem is specific to Windows, given that it worked on one Windows machine and not the other, and also given that Sublime seemed to be internally consistent about the options being disabled (both in the drop-down menu and in the Ctrl-P actions window).

It seemed more like the kind of thing that would result from a bug in the implementation of is_enabled in the Sublime WindowCommand API. I haven't taken a lot at your source yet to see if or how you implement is_enabled

https://www.sublimetext.com/docs/3/api_reference.html#sublime_plugin.WindowCommand

@reagle

This comment has been minimized.

Copy link

commented May 21, 2019

I have this problem too! My shortcut stopped working and when looking at the menu bar I see the filter options are grayed out (but fold continues to be available and work). Nothing in the console. ST3:3188 MacOS Mojave.

@reagle

This comment has been minimized.

Copy link

commented May 21, 2019

Screen Shot 2019-05-21 at 7 57 52 AM

@uglycoyote

This comment has been minimized.

Copy link
Author

commented May 21, 2019

FWIW, I have not encountered this problem again since I reported it and I use the plugin fairly frequently. I don't have any more insight in to what might have triggered the bug or what might have made it disappear. But seeing another user with the problem and having it in Mac at least means I'm not the only one and it is not platform specific.

@reagle

This comment has been minimized.

Copy link

commented May 21, 2019

I deleted the package, exited, launched, and reinstalled the package and the problem persists.

@uglycoyote

This comment has been minimized.

Copy link
Author

commented May 21, 2019

I previously theorized that it might be a bug in this plugin's implementation of is_enabled in the Plugin API Reference

Methods Return Value Description
is_enabled() bool Returns True if the command is able to be run at this time. The default implementation simply always returns True.

But now that I searched the source code of the sublime-filterlines plugin I realize that it has no implementation of is_enabled and so if the docs are still correct it should always be enabled. So it makes very little sense that it would grey out the plugin menu options.

Something to try, if you are inclined to monkey with the source code, would be to add an explicit implementation of is_enabled in the plugin which always returns true. (in case the fallback is_enabled may actually do something different than what is documented). Maybe this is more of a Sublime Text bug than a filterlines plugin bug? I google searched and found a few other cases of people complaining about random plugins having their options greyed out.

@reagle

This comment has been minimized.

Copy link

commented May 29, 2019

I just got 3.1.3 and hoped there was a fix but the problem is still present.

@uglycoyote

This comment has been minimized.

Copy link
Author

commented May 29, 2019

You should probably assume that it is not fixed unless @davidpeckham closes this issue. Seeing as he has never even said that he is able to reproduce the issue, I think it is not likely to get fixed in the near future.

@reagle

This comment has been minimized.

Copy link

commented Aug 6, 2019

I still have this problem. I stepped back through to 3.0.0 in git and still had the problem.

● cab3139 (HEAD, tag: st3-3.0.0) Release notes update (4 years, 7 months ago) <David Peckham>
@reagle

This comment has been minimized.

Copy link

commented Aug 6, 2019

Running the latest from Package Control. I thought I'd try to see if it's another plugin and discovered that if I remove or install a package (doesn't matter which) the filter lines functionality might be available for a short period until it disappears again. I don't see any debug info on the console though.

Update: If it is present, something as simple as opening or closing a file causes it to disappear.

@davidpeckham davidpeckham self-assigned this Aug 6, 2019

@davidpeckham davidpeckham added the bug label Aug 6, 2019

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 6, 2019

I appreciate the testing both of you have done to isolate this. I’ll take another look at this soon and see what I can do.

@uglycoyote

This comment has been minimized.

Copy link
Author

commented Aug 6, 2019

I posted this question to the sublime plugin development forum to see if anyone had any clues about what else makes the plugin menu items become greyed out. (besides the is_enabled callback which this plugin does not use)

https://forum.sublimetext.com/t/what-are-reasons-why-sublime-would-grey-out-a-plugins-menu-options/45828

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 7, 2019

When the menus are disabled, are you able to run the filter or fold commands from the Command Palette?

@reagle

This comment has been minimized.

Copy link

commented Aug 7, 2019

No, there is no entry in the command palette for those commands.

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 7, 2019

I see that ST 3 added a new way to collect user input for commands, and it looks like a better user experience. I'm going to rewrite the to use Command Palette input, and try to simplify it along the way.

Would you be willing to test it for me?

@reagle

This comment has been minimized.

Copy link

commented Aug 7, 2019

Yes. Perhaps you could you also add more diagnostics to help debug? (Not sure what though.)

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 7, 2019

I read your comment on the ST forum about fold commands still working when the filter commands don’t. That’s very helpful.

@FichteFoll

This comment has been minimized.

Copy link

commented Aug 7, 2019

I took a brief look at the plugin code and couldn't exactly spot anything out of the ordinary that could cause the described symptoms, especially considering that it only happens occasionally.

What other plugins do you have installed? Could they be interfering with module loading? When the menu items are grayed out, does the console indicate that the filter plugin has been loaded? It might help to post the entire console's contents when you notice the issue again.

@reagle

This comment has been minimized.

Copy link

commented Aug 8, 2019

@davidpeckham, yes "fold" continues to work. That was reported in the first message above and in two of my comments, but I see a later comment from me could've muddled things.

@reagle

This comment has been minimized.

Copy link

commented Aug 8, 2019

This screencapture corresponds to a session of starting ST, of filter lines not being present, of removing a plugin (doesn't matter which), of it returning to the menu, of the filtering working (sometimes it doesn't, it doesn't do anything), of installing a plugin, and of the command disappearing. The corresponding log is here.

@FichteFoll

This comment has been minimized.

Copy link

commented Aug 8, 2019

Okay, I do have an idea after all. While not certain, you are importing the filter commands into fold.py, which causes the ST plugin loaded to scan the two filter commands again, since it scans every Python file in the package root for any classes that subclass a sublime_plugin class.

A suggested solution would be to merge fold.py into filter.py so that ST only loads a single plugin. The files aren't that long anyway.

This still doesn't really explain why uninstalling a package and reinstalling it makes it work again, but that's at least something noteworthy. The console log above looks perfectly fine.

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 8, 2019

That’s a good point. I’ll combine them and push a release later today or tomorrow.

Thanks

davidpeckham added a commit that referenced this issue Aug 8, 2019

Possible fix for issue #53
Merged fold.py into filter.py, at FichteFoll's suggestion, to prevent ST 3 from greying out our menu items.
@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 8, 2019

Here is an updated package with the fix FichteFoll suggested. Uninstall Filter Lines before you copy this into Packages/User/.

sublime-filterlines.sublime-package.zip

@reagle

This comment has been minimized.

Copy link

commented Aug 8, 2019

Working great so far!

davidpeckham added a commit that referenced this issue Aug 9, 2019

@davidpeckham

This comment has been minimized.

Copy link
Owner

commented Aug 9, 2019

I released 3.1.4 with this change. Thank you @uglycoyote, @reagle, and @FichteFoll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.