Commit caafa197 authored by Steve Frécinaux's avatar Steve Frécinaux

bug #333326, bug #332384 (patch by jesse)

parent d915a8d0
2006-03-05 Jesse van den Kieboom <jesse@icecrew.nl>
* plugins/snippets/snippets/SnippetController.py:
fixed Ctrl+space being stopped from handling even if snippets doesn't
show a popup dialog (see bug #333326). Fixed handling of single
non-alphanumeric tab triggers
* plugins/snippets/snippets/SnippetsLibrary.py:
fixed loading of duplicate system snippets (see bug #332384)
2006-03-04 Paolo Maggi <paolo@gnome.org>
* gedit/gedit-languages-manager.c (string_to_tag_style):
......
......@@ -129,7 +129,7 @@ class SnippetController:
self.apply_snippet(snippets[0])
else:
# Do the fancy completion dialog
self.show_completion(snippets)
return self.show_completion(snippets)
return True
......@@ -322,8 +322,8 @@ class SnippetController:
if not word or word == '':
if start.backward_char():
word = start.get_char()
if word.isspace():
if word.isalnum() or word.isspace():
return (None, None, None)
else:
return (None, None, None)
......@@ -349,7 +349,7 @@ class SnippetController:
self.apply_snippet(snippets[0], start, end)
else:
# Do the fancy completion dialog
self.show_completion(snippets)
return self.show_completion(snippets)
return True
......@@ -429,7 +429,7 @@ class SnippetController:
# If there is no prefix, than take the insertion point as the end
end = buf.get_iter_at_mark(buf.get_insert())
if not preset:
if not preset or len(preset) == 0:
# There is no preset, find all the global snippets and the language
# specific snippets
......@@ -438,7 +438,18 @@ class SnippetController:
if self.language_name:
nodes += SnippetsLibrary().get_snippets(self.language_name)
complete = SnippetComplete(nodes, prefix, True)
if prefix and len(prefix) == 1 and not prefix.isalnum():
hasnodes = False
for node in nodes:
if node['tag'] and node['tag'].startswith(prefix):
hasnodes = True
break
if not hasnodes:
prefix = None
complete = SnippetComplete(nodes, prefix, False)
else:
# There is a preset, so show that preset
complete = SnippetComplete(preset, None, True)
......@@ -452,7 +463,7 @@ class SnippetController:
(xor, yor) = win.get_origin()
self.move_completion_window(complete, x + xor, y + yor)
complete.run()
return complete.run()
def update_snippet_contents(self):
self.idle_update_id = 0
......@@ -517,7 +528,6 @@ class SnippetController:
not (event.state & gdk.MOD1_MASK) and \
not (event.state & gdk.SHIFT_MASK) and \
event.keyval in self.SPACE_KEY_VAL:
self.show_completion()
return True
return self.show_completion()
return False
......@@ -559,16 +559,7 @@ class SnippetsLibraryImpl:
self._accelerator_activated_cb = None
self.loaded = False
# Contains all the language containers which have tag/accel mappings
self.containers = {}
# Contains all the library file mappings
self.libraries = {}
# Contains the suppressed snippets
self.overridden = {}
def set_dirs(self, userdir, systemdirs):
self.userdir = userdir
self.systemdirs = systemdirs
......@@ -576,6 +567,7 @@ class SnippetsLibraryImpl:
self.libraries = {}
self.containers = {}
self.overridden = {}
self.loaded_ids = []
self.loaded = False
......@@ -596,13 +588,21 @@ class SnippetsLibraryImpl:
return None
snippet = SnippetData(element, library)
snippet = container.append(snippet)
if snippet.id in self.loaded_ids:
snippets_debug('Not added snippet ' + str(library.language) + \
'::' + snippet['description'] + ' (duplicate)')
return None
snippet = container.append(snippet)
snippets_debug('Added snippet ' + str(library.language) + '::' + \
snippet['description'])
if snippet and snippet.override:
self.add_override(snippet)
if snippet.id:
self.loaded_ids.append(snippet.id)
return snippet
......@@ -749,11 +749,16 @@ class SnippetsLibraryImpl:
return language
def remove_overrides(self, language):
def remove_container(self, language):
for snippet in self.containers[language].snippets:
if snippet.id in self.loaded_ids:
self.loaded_ids.remove(snippet.id)
if snippet.override in self.overridden:
del self.overridden[snippet.override]
del self.containers[language]
def get_accel_group(self, language):
language = self.normalize_language(language)
......@@ -788,9 +793,7 @@ class SnippetsLibraryImpl:
for library in self.libraries[language]:
library.unload()
self.remove_overrides(language)
del self.containers[language]
self.remove_container(language)
def ensure(self, language):
language = self.normalize_language(language)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment