Snippets Plugin: Cannot add snippets to languages that don't have any

Bug #35613 reported by Arthur Peters
12
Affects Status Importance Assigned to Milestone
gedit (Ubuntu)
Fix Released
Medium
Ubuntu Desktop Bugs

Bug Description

In the Snippets Plugin "Snippet Manager" dialog you can only add new snippets to languages that already have a system-wide snippets XML file. For others, the GUI simply shows no change and the following appears on the console:

Traceback (most recent call last):
  File "/usr/lib/gedit-2/plugins/snippets/SnippetsDialog.py", line 431, in on_cell_edited
    snippet = self.new_snippet({'description': new_text})
  File "/usr/lib/gedit-2/plugins/snippets/SnippetsDialog.py", line 359, in new_snippet
    self.language_path), properties)
  File "/usr/lib/gedit-2/plugins/snippets/SnippetsLibrary.py", line 638, in new_snippet
    library = self.get_user_library(language)
  File "/usr/lib/gedit-2/plugins/snippets/SnippetsLibrary.py", line 620, in get_user_library
    for library in self.libraries[language]:
KeyError: 'pascal'

I wrote a patch (attached) that changes the mentioned "self.libraries[language]" to "self.libraries.get(language, [])". I tested this patch and it works. I think this is probably a good solution, however before I thought of this I created a patch that simply adds snippets xml files for all languages (also attach), but I never tested it.

Thanks.

Revision history for this message
Arthur Peters (amp) wrote : Fix by changing the code

A single line change that allows a user local snippets file to be created even if a global one does not exist.

Revision history for this message
Arthur Peters (amp) wrote : Fix by adding snippets file for each language

Just because a did it. The other fix it is prolly better.

Revision history for this message
Jesse van den Kieboom (jesse-icecrew) wrote :

This bug is also reported upstream (http://bugzilla.gnome.org/show_bug.cgi?id=334638) and a patch is attached. The sollution is the same as your suggested patch no 1.

Revision history for this message
Paolo Borelli (pborelli) wrote :

fixed upstream:

2006-03-19 Jesse van den Kieboom <email address hidden>

 * plugins/snippets/snippets/SnippetsLibrary.py: fix bug 334638
 patch by Arthur Peters.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you Paolo!

Changed in gedit:
assignee: nobody → desktop-bugs
status: Unconfirmed → Fix Committed
Revision history for this message
Daniel Holbach (dholbach) wrote :

 gedit (2.14.2-0ubuntu1) dapper; urgency=low
 .
   * New upstream release:
     - bugfixes to the external tools plugin (Malone: #34869)
     - bugfixes to the snippets plugin (Malone: #35613)
     - misc bugfixes
     - New and updated translations: vi, es, be, et, br, dz, ka.
   * debian/control.in:
     - Recommends: python-gnome2-desktop. (Malone: #37295)
   * debian/patches/02_autoconf.patch:
     - updated.

Changed in gedit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.