No response with the tab-key, cause wrong template file

Bug #124511 reported by Daniel Ekelund
2
Affects Status Importance Assigned to Milestone
Snipper
New
Undecided
Unassigned

Bug Description

My report contains two parts,

Part one:

When you hit tab the python source code

except KeyError:
      # There is no buffer at hand for the current filetype, try redetecting the type
      self.registerBuffer()
      try:
        self.buffers[self.helper.getFiletype()]
        if buffer == None:
          raise NoTemplateFoundException()
      except:
        raise NoTemplateFoundException()

runs, but it doesn't work. The code should have this line:
return buffer
and if the registerBuffer() method change behaviour you may need this row, with assignment:
buffer = self.buffers[self.helper.getFiletype()]
instead of
self.buffers[self.helper.getFiletype()]

look at this version of the code to see what I did to solve it (CHANGES MAKED WITH << >>):
     except KeyError:
       # There is no buffer at hand for the current filetype, try redetecting the type
       self.registerBuffer()
       try:
         << buffer = self.buffers[self.helper.getFiletype()] >>
         if buffer == None:
           raise NoTemplateFoundException()
         << return buffer >>
       except:
         raise NoTemplateFoundException()

Now to the second part of my patch, if you use this row

if filetype.lower() in file.lower():

in this part of the code

for file in self.template_files:
      if filetype.lower() in file.lower():
        bfile = open(self.template_folder + "/" + file, 'r')
        return Buffer(bfile)

you will end up using GtkRC-templates.xml instead of C-templates.xml when you edit a C file.
Solution, use this line:

if file.lower().startswith(filetype.lower()):

Good luck and happy hacking...

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.