SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

You MUST use spaces! error: Syntax tests do not work properly with tabs as indentation. #177

Closed evandrocoan closed 2 years ago

evandrocoan commented 6 years ago

So, I press Ctrl+P and start typing a file I would like to open, then BAM! You do not even let me complete type the file name gotolasteditenhanced.

image

I would happen to accidentally hit a syntax file which uses tabs as indentation:

File: Data/Packages/PackageDev/plugins_/syntaxtest_dev.py
29: def _show_tab_warning():
30:     sublime.error_message("Syntax tests do not work properly with tabs as indentation."
31:                           "\n\nYou MUST use spaces!")
32: 

Your warning seem too aggressive popping up on a error message dialog. Also, very frustrating while using the Ctrl+P/Go To Anything... feature.

Why not just using print on the user console, perhaps also a sublime.status_message instead of sublime.error_message or sublime.message_dialog?

FichteFoll commented 6 years ago

Well, I specifically wanted this to get in the way of user experience so the user can fix their faulty indentation settings for syntax test files, so a print message on the console is a no-go.

There is no easy way for me to find out whether a view has been opened transiently from the Go To Anything panel and delay the message until it was really opened. I guess I could try to see whether on_activated messages can do any good for me, although it would require me to rework the logic around this "feature" quite a bit.

Edit: I know it's not really your syntax test file, but if it annoys enough people, someone might actually submit a PR to fix that. For the record, the current file does indeed use tabs for indentation, although in a way that it works. It's not recommended regardless and should be changed because of how fragile this can turn out to be if you end up with mixed indentation between code and test lines.

FichteFoll commented 5 years ago

Would be a lot easier if I could just check whether a quick panel is visible :/

Suggestions welcome, otherwise I'm inclined to not fix this (and rather fix https://github.com/sublimehq/Packages/issues/1361 instead).

evandrocoan commented 5 years ago

I think we check whether there is a quick panel open, if it is with focused. If not, we could wait Sublime Text allow to check whether the quick panel is open.

FichteFoll commented 5 years ago

I think we check whether there is a quick panel open

I just mentioned that we can't, though, unless you know of some very hacky way that I'm not sure I'd want to rely on.