11 Commits

Author SHA1 Message Date
Allan Odgaard
d11874b4c3 Order sections in Global.tmProperties
We can have multiple file patterns match the path for which we ask for settings, so the order of sections does matter, as we’ll use the setting from the last section with a match.

The order enforced is based on length though with a leading asterisk subtracted from the length, that way ‘*.txt’ will be placed before ‘CMakeLists.txt’ and ‘*.rb’ will go before ‘*_spec.rb’.

Incase of same length, we use regular string compare which would normally put the wildcard match first, e.g. ‘*.config’ goes before ‘.config’.
2016-09-04 20:17:42 +02:00
Allan Odgaard
3046ccd50d Add slash to folder when searching settings for untitled documents
That way, if we have a setting for [ templates/** ] and create a new file in the templates folder (via the file browser) these settings will apply.

Previously we used the folder without trailing slash which required making the file pattern something like [ templates{/**,} ].
2016-07-14 12:21:28 +02:00
Allan Odgaard
431bba9a2e Change precedence of targeted settings
Settings are now ranked by locality first, and only if multiple settings from the same .tm_properties file apply, we rank them further using the following order (from lowest to highest): untargeted, scoped (ranked by scope selector), and finally file pattern match (glob).
2016-07-06 18:59:02 +02:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
45db36234c File path settings now rank higher than scope settings
A file setting like “src/*.cc” is arguably more specific (and thus more local) than targeting the scope “source.c++”, so it makes sense that the file settings rank higher than scope settings.

Some users also find it natural to target file extensions over scopes, but as TM will store some learned settings with a scope selector, it would previously lead to confusion, when a user was unable to e.g. change tab size for “*.php” (because TM had a learned setting for “source.php”).
2013-12-14 12:57:24 +07:00
Allan Odgaard
a3ec258912 Update settings tests to new system 2013-02-25 15:25:17 +01:00
Allan Odgaard
b718106ff8 Make semi-internal API private
This was previously public so that we could write tests for it, but since the test runner is linked with the object files, it can access symbols that has visibility set to hidden.
2013-02-23 11:24:56 +01:00
Allan Odgaard
6cd18bafb0 Allow property sections to match folders
We generally lookup include/exclude patterns for a folder rather than a file, and here it makes sense to allow the bracketed sections of the property files to target the folder.

Since the sections are not ranked based on how good a match they are, targeting a subfolder, and then a subfolder of this subfolder, does not have which settings take precedence defined.
2013-01-28 21:01:12 +01:00
Allan Odgaard
923dab6375 Scoped properties are now applied last
This is so that a global setting for ‘source.ruby’ takes precedence over a local ‘source’ setting.

A minor downside is that a local properties file cannot use scoped settings outside a scope selector section.
2012-09-16 11:41:24 +02:00
Allan Odgaard
15ba1374ca Add settings_t saving tests 2012-08-26 01:26:16 +02:00
Allan Odgaard
9894969e67 Initial commit 2012-08-09 16:25:56 +02:00