Fixed the naming problem

This commit is contained in:
capitaomorte 2009-11-06 17:12:03 +00:00
parent 73dc27384c
commit 859ae946da

View File

@ -154,13 +154,26 @@ class TmSnippet
doc << "# condition: \"#{self.scope}\"\n" doc << "# condition: \"#{self.scope}\"\n"
end end
doc << "# --\n" doc << "# --\n"
if self.content
@@known_substitutions.each {|level| level.each_pair { |k, v| self.content.gsub!(k,v) }} @@known_substitutions.each {|level| level.each_pair { |k, v| self.content.gsub!(k,v) }}
doc << "#{self.content}" doc << "#{self.content}"
end end
doc
end
def canonicalize(filename)
invalid_char = /[^ a-z_0-9.+=~(){}'"'"'`&#,-]/i
filename.
gsub(invalid_char, ''). # remove invalid characters
gsub(/ {2,}/,' '). # squeeze repeated spaces into a single one
rstrip # remove trailing whitespaces
end
def yasnippet_file(basedir) def yasnippet_file(basedir)
basedir = File.join(basedir,group) if group # files cannot end with dots (followed by spaces) on windows
File.join(basedir,@file).gsub(/#{File.extname(@file)}$/,".yasnippet") basedir = File.join(basedir,group.gsub(/[.]+ *$/,'')) if group
File.join(basedir,canonicalize(@file[0, @file.length-File.extname(@file).length]) + ".yasnippet")
end end
end end