changeset 26480:4203f6e0cd7d stable

Allow indent of mid block keywords (#55276) * libgui/src/m-editor/octave-qscintilla.cc (octave_qscintilla::smart_indent): add unwind_protect_cleanup, case and otherwise to mid block keys, (octave_qscintilla::smart_indent_line_or_selected_text): add processing of mid block keys
author John Donoghue
date Sat, 29 Dec 2018 09:23:11 -0500
parents 6f22d0c91beb
children 9f9aa7e92826
files libgui/src/m-editor/octave-qscintilla.cc
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Mon Jan 07 09:40:17 2019 +0100
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Sat Dec 29 09:23:11 2018 -0500
@@ -506,7 +506,7 @@
 
     QRegExp bkey = QRegExp ("^[\t ]*(if|for|while|switch|case|otherwise"
                             "|do|function|properties|events|classdef"
-                            "|unwind_protect|unwind_protect_cleanup|try"
+                            "|unwind_protect|try"
                             "|parfor|methods)"
                             "[\r]?[\n\t #%]");
     // last word except for comments, assuming no ' or " in comment.
@@ -549,7 +549,8 @@
         return;
       }
 
-    QRegExp mkey = QRegExp ("^[\t ]*(else|elseif|catch)[\r]?[\t #%\n]");
+    QRegExp mkey = QRegExp ("^[\t ]*(else|elseif|catch|unwind_protect_cleanup"
+                            "|case|otherwise)[\r]?[\t #%\n]");
     if (prevline.contains (mkey))
       {
         int prev_ind = indentation (line-1);
@@ -566,7 +567,7 @@
       }
 
     ekey = QRegExp ("^[\t ]*(end|endif|endfor|endwhile|until|endfunction"
-                    "|end_try_catch|end_unwind_protext)[\r]?[\t #%\n(;]");
+                    "|end_try_catch|end_unwind_protect)[\r]?[\t #%\n(;]");
     if (prevline.contains (ekey))
       {
         if (indentation (line-1) <= indentation (line))
@@ -595,6 +596,12 @@
                  "|unwind_protect|unwind_protect_cleanup|try|catch)"
                  "[\r\n\t #%]");
 
+    QRegExp mid_block_regexp
+      = QRegExp ("^([\t ]*)(elseif|else"
+                 "|otherwise"
+                 "|unwind_protect_cleanup|catch)"
+                 "[\r\n\t #%]");
+
     QRegExp end_block_regexp
       = QRegExp ("^([\t ]*)(end"
                  "|end(for|function|if|parfor|switch|while"
@@ -636,6 +643,9 @@
         if (end_block_regexp.indexIn (line_text) > -1)
           indent_column -= indent_increment;
 
+        if (mid_block_regexp.indexIn (line_text) > -1)
+            indent_column -= indent_increment;
+
         setIndentation (line, indent_column);
 
         if (begin_block_regexp.indexIn (line_text) > -1)