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

only show warnings if no errors OR sublime_linter_goto_error ignores warnings if there are errors #1844

Open
ta946 opened this issue Feb 4, 2022 · 5 comments

Comments

@ta946
Copy link

ta946 commented Feb 4, 2022

I want to easily focus on fixing any errors in my code by calling "sublime_linter_goto_error" and check if there are any errors.
But the navigation is just in chronological order rather than priority, so I would have to go through warnings to see if there are any errors.

Is there a command in flake8 or SublimeLinter to hide warnings if there are any errors so they are more obvious and easier to find and navigate to?
Alternatively, which would be better, is there an option in SublimeLinter for "sublime_linter_goto_error" to only go to errors if there are any errors, and only goto warnings if there are no errors?

@kaste kaste transferred this issue from SublimeLinter/SublimeLinter-flake8 Feb 4, 2022
@kaste
Copy link
Contributor

kaste commented Feb 4, 2022

Actually I find both ideas interesting.. We don't have neither.

We have for example

    "highlights.demote_while_editing": "warnings",

as a global setting which will then not draw underlines, marked regions while editing. But you can still "goto" them as there are also still visible in the error panel. (And summed in the status bar.)

Of course it is a bit confusing if you have a lot of highlighted areas in the buffer (for example warnings) but you can't go to them. If you instead hide them, you probably want to inform the users: btw there are also some warnings currently hidden. Also should this be global switch or one per linter?

That's not trivial to design. You can try to make implementations to see how it feels. Or discuss the idea in more depth here. I moved the issue to the "SublimeLinter" core repo as that's the place where it would get implemented anyway.

@ta946
Copy link
Author

ta946 commented Feb 4, 2022

Yea, I agree with you about not wanting to hide the warnings so that the user can know there are warnings. And about the confusion of seeing the warning but not being able to navigate to them.

So I was thinking the ideal implementation would be to have an argument that can be passed to "sublime_linter_goto_error", eg: skip_warnings_if_errors or whatever
That way you can create a new keyboard shortcut that doesn't change the default behaviour.

if the skip_warnings_if_errors flag is True, the goto command would check the "mistake" list for errors and goto the next one. and if there are no errors, then resume the default behaviour.

@kaste
Copy link
Contributor

kaste commented Feb 4, 2022

That's a way to make it backwards compatible but maybe doesn't solve the ux problem. For example, I usually don't want two different key bindings to jump around. And it is hard to imagine that I never want to jump to the exact next highlighted area which could be an error, a warning, a note.

But maybe try that implementation first; it's simple to do and we can see how it feels.

@ta946
Copy link
Author

ta946 commented Feb 8, 2022

I understand what you mean, but since they are 2 different uses, with this new one being more restrictive than the default. The only way is to either have 2 shortcuts if you want both uses, or if you don't want to have 2 shortcuts you'd have to pick the one you prefer

I created a fork to test the implementation ta946@a6a6c37

Luckily it was very easy, filter the list for errors only, If there are any errors, replace the original list with the errors only list (without modifying the original list) and continue with the goto logic.

just need to add a new keyboard shortcut like so
{ "keys": ["ctrl+down"], "command": "sublime_linter_goto_error", "args": {"direction": "next", "skip_warnings_if_errors": true}},

@kaste
Copy link
Contributor

kaste commented Feb 10, 2022

Haha, that's indeed a trivial patch. Let's see how it feels.

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

No branches or pull requests

2 participants