Templates/TemplateViewer.py

branch
5_0_x
changeset 505
2219cb4f46c5
parent 108
03d3adf59bde
child 792
a13346916170
--- a/Templates/TemplateViewer.py	Fri Aug 13 11:16:25 2010 +0200
+++ b/Templates/TemplateViewer.py	Fri Aug 13 12:32:03 2010 +0200
@@ -674,13 +674,16 @@
             # It should be done in this way to allow undo
             editor.beginUndoAction()
             if editor.hasSelectedText():
-                line = editor.getSelection()[0]
+                line, index = editor.getSelection()[0:2]
                 editor.removeSelectedText()
             else:
-                line = editor.getCursorPosition()[0]
+                line, index = editor.getCursorPosition()
             
-            if len(indent) > 0:
-                count += len(indent)
+            if lines == 1:
+                count += index
+            else:
+                if len(indent) > 0:
+                    count += len(indent)
             
             if "i_n_s_e_r_t_i_o_n" in txt and "s_e_l_e_c_t" in txt:
                 txt = "'Insertion and selection can not be in template together'"
@@ -691,8 +694,11 @@
                     count =  aline.find("i_n_s_e_r_t_i_o_n")
                     if count >= 0:
                         txt = txt.replace("i_n_s_e_r_t_i_o_n",  "")
-                        if len(indent) > 0:
-                            count += len(indent)
+                        if lines == 1:
+                            count += index
+                        else:
+                            if len(indent) > 0:
+                                count += len(indent)
                         break
                     else:
                         lines += 1

eric ide

mercurial