changeset 27223:1ae91e5d70cc

fix auto-close feature in editor when using tabs for indentation (bug #56533) * octave-qscintilla.cc (auto_close): do not consider new inserted line for detecting a required closing sstatement since this line has indentation indicating that there already is a close satement, us indentation method instead of adding spaces for indenting the line with the close statement
author Torsten Lilge <ttl-octave@mailbox.org>
date Thu, 04 Jul 2019 21:14:09 +0200
parents f5b967060442
children 9b8903d3e626
files libgui/src/m-editor/octave-qscintilla.cc
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Thu Jul 04 10:27:57 2019 -0400
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Thu Jul 04 21:14:09 2019 +0200
@@ -966,7 +966,8 @@
     //       end* (until) (catch)
     if (linenr < lines () - 1)
       {
-        int offset = 1;
+        int offset = 2;     // linenr is the old line, thus, linnr+1 is the
+                            // new one and can not be taken into account
         size_t next_start;
         QString next_line;
 
@@ -1027,7 +1028,9 @@
         next_line = "end" + first_word + "\n";
       }
 
-    insertAt (QString (start, ' ') + next_line, linenr + 2, 0);
+    //insertAt (QString (start, ' ') + next_line, linenr + 2, 0);
+    insertAt (next_line, linenr + 2, 0);
+    setIndentation (linenr + 2, indentation (linenr));
   }
 
   void octave_qscintilla::dragEnterEvent (QDragEnterEvent *e)