From fe4f7847209bd7e02216313afc16f0b29273c4ee Mon Sep 17 00:00:00 2001 From: Peter Foley Date: Sat, 29 Jun 2013 22:54:26 +1000 Subject: [PATCH] Fixed edge case with multiple init directories In the instance of calling the class snippet within a puppet file located in /home/pjfoley/puppet/modules/profile/manifests/server/init/init.pp I would expect the return value to be "profile::server::init", it currently returns "profile::server" which is missing a module path layer. --- UltiSnips/puppet.snippets | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/UltiSnips/puppet.snippets b/UltiSnips/puppet.snippets index 75f5127..63cb715 100644 --- a/UltiSnips/puppet.snippets +++ b/UltiSnips/puppet.snippets @@ -14,17 +14,15 @@ def get_module_namespace_and_basename(): * /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd * /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql """ + first_time = True current_file_path_without_ext = vim.eval('expand("%:p:r")') or "" if not current_file_path_without_ext: return "name" parts = os.path.split(current_file_path_without_ext) namespace = '' while parts[0] and parts[0] != '/': - # Skip the init.pp files because they don't create a deeper namespace - # and are special. Note this might break things like - # modules/collectd/init/test.pp. But I am not even sure if puppet will - # work for those. - if parts[1] == 'init': + if parts[1] == 'init' and first_time and not namespace: + first_time = False parts = os.path.split(parts[0]) continue if parts[1] == 'manifests':