averrin / color-tabs-regex

Use color-tabs package with regex.
https://atom.io/packages/color-tabs-regex
MIT License
8 stars 6 forks source link

Implement "children" rules #5

Closed bojidar-bg closed 9 years ago

bojidar-bg commented 9 years ago

Currently my CSON file looks like:

"**/projectPath/subFolder/**/*.js" : "rgb(0,255,0)"
"**/projectPath/project.json" : "rgb(0,0,255)"
"**/projectPath/**/*.cfg" : "rgb(255,0,0)"
//...

It will be much cleaner if it was like:

"**/projectPath/":
    "subFolder/**/*.js" : "rgb(0,255,0)"
    "project.json" : "rgb(0,0,255)"
    "**/*.cfg" : "rgb(255,0,0)"

The easiest way to implement this I can think of is to concatenate the strings of the "parent" rule and the "child" rule.

(Note that rule inside rules inside rules inside rules should also be supported)

P.S. if you aren't as fast as the last time, I might make a PR :smiley:

averrin commented 9 years ago

Ok, but, plz, dont break support of String.match and basic "plain" rules. For "projectPath" i suggest implement coffeescript templating: "#{projectPath}"

bojidar-bg commented 9 years ago

I think that it won't affect basic (regex) rules, because it will just concatenate strings.. And currently regexes are represented as Strings (see this stackoverflow question for details), so it shouldn't be a problem.

And about the templating, I like the idea, though it need a separate issue :smile:... actually I meant some project path, cus I don't want to color the tabs of all my projects..

@averrin And again, thank you for making this great package :+1:¹⁰⁰

bojidar-bg commented 9 years ago

@averrin Ok, I made the PR :smiley:

bojidar-bg commented 9 years ago

Now... I guess it's time for a new tag? :smile:

averrin commented 9 years ago

Im not very good in coffeescript too, but after some magic it works=) Need some more documentation in README (pr is welcome=))) ) and i will publish it

bojidar-bg commented 9 years ago

@averrin Ok, maybe a bit later I can make some docs for the new feature :smile:

averrin commented 9 years ago

@bojidar-bg sorry, i missed, that you are update readme already.

averrin commented 9 years ago

published

bojidar-bg commented 9 years ago

@averrin ~ Well, can you surround that sample code in ``` instead of ? (so it will be multiline)

averrin commented 9 years ago

I did it before publishing=)

bojidar-bg commented 9 years ago

LOL, didn't notice it ... xD

bojidar-bg commented 9 years ago

Nice.. I found a bug :smile: I can't have more than two levels of rules, e.g.

"**/Projects/":
  "nodejs/":
    "**/package.json": "red" # This won't ever make a match...
  "someProject/**/*.js": "green"

I think that if line 69 https://github.com/averrin/color-tabs-regex/blob/master/lib/color-tabs-regex.coffee#L69 is changed to

        output = @expandRules(rules[rule], prefix + rule, output)
                                           ^^^^^^^^^ <- Added

this bug will not happen :smile:.

Sorry for sending such buggy code to you...

bojidar-bg commented 9 years ago

You repoened it just in order to close it? o.O

averrin commented 9 years ago

I confirmed this bug, and fix it.=)

bojidar-bg commented 9 years ago

=)