changeset 27684:becd6267d6d1

hide tmp file in error and bp messages when executing selected code (bug #57205) * octave-qscintilla.cc (contextmenu_run): check lines to be executed for the use of keyboard and use __db_next_breakpoint_quiet__ for hiding bp location, remove line/col number and file name from error messages remove line/column number, file name
author Torsten Lilge <ttl-octave@mailbox.org>
date Wed, 13 Nov 2019 18:58:32 +0100
parents 6604b41ca63f
children cb656f5fa083
files libgui/src/m-editor/octave-qscintilla.cc
diffstat 1 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Wed Nov 13 09:37:26 2019 -0800
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Wed Nov 13 18:58:32 2019 +0100
@@ -839,8 +839,23 @@
         QString line = lines.at (i);
         line = line.replace (QString ("%"), QString ("%%"));
 
+        // Prevent output of breakpoint in temp. file for keyboard
+        QString next_bp_quiet;
+        QString next_bp_quiet_reset;
+        if (line.contains ("keyboard"))
+          {
+            // Define commands for not showing bp location and for resetting
+            // thisin case "keyboard" was within a comment
+            next_bp_quiet = "__db_next_breakpoint_quiet__;\n";
+            next_bp_quiet_reset = "__db_next_breakpoint_quiet__(false);\n";
+          }
+
+        // Add codeline togetcher with call to echo/hitory function to tmp
         code += QString ("%1 (%2, '%3', '%4');\n"
-                         "%4\n\n")
+                          + next_bp_quiet
+                          + "%4\n"
+                          + next_bp_quiet_reset
+                          + "\n")
                          .arg (tmp_script_name)
                          .arg (i)
                          .arg (lines.at (i))
@@ -898,7 +913,26 @@
              Frmpath (interp, path);
              emit ctx_menu_run_finished_signal (show_dbg_file,
                                                 tmp_file, tmp_hist, tmp_script);
-             throw (e);
+
+             // Drop line and column from error message
+             std::size_t line_pos = e.message ().find ("near line");
+             std::string new_msg = e.message ();
+             if (line_pos != std::string::npos)
+               {
+                 new_msg = e.message ().substr (0, line_pos);
+                 new_msg.append ("near line 1, column 1");
+               }
+
+             // Drop first stack level, i.e. temporary function file
+             std::list<frame_info> stack = e.stack_info ();
+             stack.pop_back ();
+
+             // New exception with updated message and stack
+             octave::execution_exception ee (e.err_type (),e.identifier (),
+                                             new_msg, stack);
+
+             // Throw
+             throw (ee);
            }
 
          // Clean up