linter-gcc icon indicating copy to clipboard operation
linter-gcc copied to clipboard

linter-gcc assumes that only one project is open

Open zjcers opened this issue 9 years ago • 5 comments

This package assumes the user only has one project open in Atom at any given time or that the project being linted was the first one to be opened. This causes errors when linter-gcc goes to look for its configuration file or those from CMake since only searches atom.project.getDirectories[0] instead of checking every element returned by that method to find the open project.

zjcers avatar Oct 17 '16 15:10 zjcers

The reason atom behaves in this way is to avoid edge cases where you have multiple projects open and linter-gcc can't work out which settings to use for which file (an example of this is having one project inside another). This is also complicated by the fact that in addition to all this, you can simply open a file anywhere on your disk which can cause even more confusion: does this file belong to a project at all? And if so which one? Does the user expect the file to be linted using global settings or project specific settings? The conclusion here is that there is no sensible way to implement this feature within linter-gcc itself, particularly when opening another window gives you everything you need.

hebaishi avatar Oct 17 '16 16:10 hebaishi

Edit: the first line should read: the reason linter-gcc behaves in this way not atom

hebaishi avatar Oct 17 '16 16:10 hebaishi

atom.project.relativizePath(openFile) is a quick way to find the owning project's base directory. It returns an array, the first index of which is the project base directory. If the file doesn't belong to a directory, that index is null. Feel free to backport my solution from zjcers/linter-cnew

zjcers avatar Oct 18 '16 21:10 zjcers

Nice work man. I think a lot of what you've done can be integrated into linter gcc. What do you think about that?

hebaishi avatar Oct 18 '16 21:10 hebaishi

Go for it. Just be aware that if you decide to merge my codebase into yours, I've rebranded the project in the last ~5 commits, so you'll want to revert it back to then. Also, pretty much the entire the thing has been rewritten, so be prepared for that (and two feature regressions as per my README). Probably best to just copy&paste the relevant sections in.

zjcers avatar Oct 19 '16 00:10 zjcers