nirm03/SublimeLinter-clang

get_project_folder breaks on unsaved files

Closed this issue · 4 comments

Unsaved files have no filename which breaks linting.

I saw this issue and made a fix to my linter contribution avr-gcc which is very closely based on (copied from) this one.
In the get_project_folder() function, I added a check to see if the filename exists and returns '.' if none is found. The extra bit of code is:

# Use current file's folder when no project file is opened.
proj_file = sublime.active_window().active_view().file_name()
if proj_file:
    return os.path.dirname(proj_file)
return '.'

See the code here: https://github.com/ChisholmKyle/SublimeLinter-contrib-avr-gcc/blob/master/linter.py#L27.

Wanna create a pull request with that or you want me to do it?

It's a little annoying to do a pull request and it's such a small change, please go for it!

I'm not sure if this should be a new topic, but adding language-specific flags (extra_cflags and extra_cxxflags) like EasyClangComplete is really a quick feature addition and doesn't have to break anything - see SublimeLinter-contrib-avr-gcc
The extra C/C++ flags are really helpful for projects with mixed C and C++ source files. What do you think?

I’m not a maintainer here (this is just my issue) but I created the PR now.
I was merely suggesting that you submit PRs if you are sure (and even if not^^) about some changes.