changeset 33439:f31a0d826776

improve running test and demos by F9 (bug #65577) * octave-qscintilla.cc (contextmenu_run): remove %! from the beginning of a selected line except only if a space is followng, exception: assert
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 21 Apr 2024 21:30:11 +0200
parents b2333101ca29
children 411e19dc791b
files libgui/src/m-editor/octave-qscintilla.cc
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Sun Apr 21 17:39:29 2024 +0200
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Sun Apr 21 21:30:11 2024 +0200
@@ -892,8 +892,17 @@
       if (line.trimmed ().isEmpty ())
         continue;
 
-      if (! line.contains (QRegularExpression("^%!(demo|test)\\s*")))
-        line.replace (QRegularExpression("^%!\\s"), "");   // allow running tests & demos
+      if (line.startsWith ("%!"))   // Handle tests and demos
+        {
+          // Do not remove %! if keyword is directly following.
+          // Exception: assert
+            {
+              // assert might be used without leading space
+              line.replace (QRegularExpression("^%!assert(\\s*)([^\\s]+)"), "assert\\1\\2");
+              // Remove "%! "
+              line.replace (QRegularExpression("^%!\\s+"), "");
+            }
+        }
 
       QString line_escaped = line;
       line_escaped.replace (QString ("'"), QString ("''"));