BETA TESTERS: this commit is broken, so ignore it.

This commit is contained in:
Liam Cain
2012-05-01 09:03:53 -04:00
parent 461b5dc8f5
commit 66cd64c040
3 changed files with 21 additions and 6 deletions

4
.gitignore vendored
View File

@@ -1 +1,3 @@
*.pyc
*.pyc
*.html
*.css

View File

@@ -49,6 +49,14 @@ class FileNameComplete(sublime_plugin.EventListener):
if key == "afn_commit-n-trim":
return self.will_commit(view) == operand
def on_selection_modified(self,view):
sel = view.sel()[0].a
if 'string.end' in view.scope_name(sel):
if view.substr(sel-1) == '/' or len(view.extract_scope(sel)) < 3:
view.run_command('auto_complete',
{'disable_auto_insert': True,
'next_completion_if_showing': False})
def will_commit(self, view):
if self.committing_filename:
self.committing_filename = False
@@ -56,9 +64,7 @@ class FileNameComplete(sublime_plugin.EventListener):
return False
def fix_dir(self,sdir,fn):
if not '.' in fn[1:]:
return fn + '/'
elif fn.endswith(('.png','.jpg','.jpeg','.gif')):
if fn.endswith(('.png','.jpg','.jpeg','.gif')):
path = os.path.join(sdir + '/', fn)
with open(path,'r') as r:
read_data = r.read()
@@ -75,11 +81,16 @@ class FileNameComplete(sublime_plugin.EventListener):
sel = view.sel()[0].a
for x in view.find_all("[a-zA-Z]+"):
backup.append(view.substr(x))
backup.append((view.substr(x),view.substr(x)))
if not any(s in view.scope_name(sel) for s in valid_scopes):
return backup
if not view.file_name():
print 'AutoFileName: File not saved.'
backup.insert(0,('AutoFileName: File Not Saved',''))
return backup
this_dir = os.path.split(view.file_name())[0] + os.path.sep
cur_path = view.substr(view.extract_scope(sel-1)).replace('\r\n', '\n').split('\n')[0]
if cur_path.startswith(("'","\"","(")):
@@ -108,6 +119,8 @@ class FileNameComplete(sublime_plugin.EventListener):
for d in list(set(dir_files)):
n = d.decode('utf-8')
if not '.' in n[1:]:
n += '/'
completions.append((self.fix_dir(this_dir,n), n))
if completions:
self.committing_filename = True

View File

@@ -3,7 +3,7 @@
//Changing this setting allows for absolute paths on a project level
//This is useful for web designers and developers who want to use the
//root of their site.
"auto_file_name_use_project_root": true,
"auto_file_name_use_project_root": false,
// Override the project root. Will only work
// if "auto_file_name_use_project_root" is true.