changeset 29934:116dbaba5a74 stable

fix opening a file in a custom editor (bug #60990) * external-editor-interface.cc (call_custom_editor): call custom editor even for valid line numbers, avoid negative line numbers * file-editor.cc (request_open_file): check preference for custom editor and if set, do nothing in case of debugging
author Torsten Lilge <ttl-octave@mailbox.org>
date Sat, 31 Jul 2021 16:07:45 +0200
parents 9ec1715a9aae
children fb0436a0c126 106aa8480569
files libgui/src/external-editor-interface.cc libgui/src/m-editor/file-editor.cc
diffstat 2 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/external-editor-interface.cc	Sat Jul 31 12:44:04 2021 +0200
+++ b/libgui/src/external-editor-interface.cc	Sat Jul 31 16:07:45 2021 +0200
@@ -46,15 +46,13 @@
   bool
   external_editor_interface::call_custom_editor (const QString& file, int line)
   {
-    if (line > -1)  // check for a specific line (debugging)
-      return true;  // yes: do not open a file in external editor
-    else
-      line = 0;     // no: start external editor at beginning of file
-
     QString editor = external_editor ();
     if (editor.isEmpty ())
       return true;
 
+    if (line < 0)
+      line = 0;
+
     // replace macros
     editor.replace ("%f", file);
     editor.replace ("%l", QString::number (line));
--- a/libgui/src/m-editor/file-editor.cc	Sat Jul 31 12:44:04 2021 +0200
+++ b/libgui/src/m-editor/file-editor.cc	Sat Jul 31 16:07:45 2021 +0200
@@ -1487,11 +1487,19 @@
                                        bool breakpoint_marker, bool insert,
                                        const QString& cond, int index)
   {
-    if (call_custom_editor (openFileName, line))
-      return;   // custom editor called
-
     resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
     gui_settings *settings = rmgr.get_settings ();
+
+    if (settings->value (global_use_custom_editor).toBool ())
+      {
+        // Custom editor
+        if (debug_pointer || breakpoint_marker)
+          return;   // Do not call custom editor during debugging
+
+        if (call_custom_editor (openFileName, line))
+          return;   // Custom editor called
+      }
+
     bool show_dbg_file
       = settings->value (ed_show_dbg_file).toBool ();