# HG changeset patch # User Torsten Lilge # Date 1714332480 -7200 # Node ID a583e8d66a197a8322314f138a561650930c0679 # Parent 3362e398d7020c923c3a5b174c5bcbfc8a69a6d5 do not change gui settings when running selected code by F9 (bug #65617) * gui-preferences-ed.cc/h: new gui preference for storing the name of the temp. file used for running selected code by F9 * file-editor.cc (request_open_file): if breakpoint oder debug marker is used and file name is equal to temp file, just return and do not open the file * octave-qscintilla.cc (contextmenu_run): do not handle lines with keyboard in a special way anymore, store file name of temp. file in settings, variable show_dbg_file and update signal and function calls accordingly; (ctx_menu_run_finished): remove temp file name from settings * octave-qscintilla.h: remove first argument show_dbg_file in signal ctx_menu_run_finished_signal and slot ctx_menu_run_finished diff -r 3362e398d702 -r a583e8d66a19 libgui/src/gui-preferences-ed.cc --- a/libgui/src/gui-preferences-ed.cc Sun Apr 28 12:03:16 2024 +0200 +++ b/libgui/src/gui-preferences-ed.cc Sun Apr 28 21:28:00 2024 +0200 @@ -234,6 +234,9 @@ QVariant (false)); gui_pref +ed_run_selection_tmp_file ("editor/run_selection_tmp_file", QVariant (QString ())); + +gui_pref ed_mru_file_list ("editor/mru_file_list", QVariant ()); gui_pref diff -r 3362e398d702 -r a583e8d66a19 libgui/src/gui-preferences-ed.h --- a/libgui/src/gui-preferences-ed.h Sun Apr 28 12:03:16 2024 +0200 +++ b/libgui/src/gui-preferences-ed.h Sun Apr 28 21:28:00 2024 +0200 @@ -202,6 +202,8 @@ extern gui_pref ed_always_reload_changed_files; +extern gui_pref ed_run_selection_tmp_file ; + extern gui_pref ed_mru_file_list; extern gui_pref ed_mru_file_encodings; diff -r 3362e398d702 -r a583e8d66a19 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Sun Apr 28 12:03:16 2024 +0200 +++ b/libgui/src/m-editor/file-editor.cc Sun Apr 28 21:28:00 2024 +0200 @@ -1713,6 +1713,10 @@ if (breakpoint_marker && ! insert) return; // Never open a file when removing breakpoints + if ((breakpoint_marker || debug_pointer) + && (openFileName == settings.string_value (ed_run_selection_tmp_file))) + return; // Never open tmp file when debugging while running selection + file_editor_tab *fileEditorTab = nullptr; // Reuse tab if it hasn't yet been modified. bool reusing = false; diff -r 3362e398d702 -r a583e8d66a19 libgui/src/m-editor/octave-qscintilla.cc --- a/libgui/src/m-editor/octave-qscintilla.cc Sun Apr 28 12:03:16 2024 +0200 +++ b/libgui/src/m-editor/octave-qscintilla.cc Sun Apr 28 21:28:00 2024 +0200 @@ -908,19 +908,8 @@ line_escaped.replace (QString ("'"), QString ("''")); QString line_history = line; - // 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 - // this in case "keyboard" was within a comment - next_bp_quiet = "__db_next_breakpoint_quiet__;\n"; - next_bp_quiet_reset = "\n__db_next_breakpoint_quiet__(false);"; - } - // Add codeline - code += next_bp_quiet + line + next_bp_quiet_reset + "\n"; + code += line + "\n"; hist += line_history + "\n"; } @@ -938,6 +927,10 @@ return; } + // Store file in settings in order to avoid opening it in editor + gui_settings settings; + settings.setValue (ed_run_selection_tmp_file.settings_key (), tmp_file->fileName ()); + // Create tmp file required for adding command to history QPointer tmp_hist = create_tmp_file ("", hist); @@ -965,12 +958,6 @@ Fhistory (interp, ovl (opt, path)); }); - // Disable opening a file at a breakpoint in case keyboard () is used - gui_settings settings; - - bool show_dbg_file = settings.bool_value (ed_show_dbg_file); - settings.setValue (ed_show_dbg_file.settings_key (), false); - // The interpreter_event callback function below emits a signal. // Because we don't control when that happens, use a guarded pointer // so that the callback can abort if this object is no longer valid. @@ -979,7 +966,7 @@ // Let the interpreter execute the tmp file emit interpreter_event - ([this, this_oq, tmp_file, tmp_hist, show_dbg_file] (interpreter& interp) + ([this, this_oq, tmp_file, tmp_hist] (interpreter& interp) { // INTERPRETER THREAD @@ -1066,7 +1053,7 @@ stack.pop_back (); // Clean up before throwing the modified error. - emit ctx_menu_run_finished_signal (show_dbg_file, err_line, + emit ctx_menu_run_finished_signal (err_line, tmp_file, tmp_hist, dbg, auto_repeat); @@ -1080,7 +1067,7 @@ // Clean up - emit ctx_menu_run_finished_signal (show_dbg_file, err_line, + emit ctx_menu_run_finished_signal (err_line, tmp_file, tmp_hist, dbg, auto_repeat); @@ -1096,7 +1083,7 @@ } void octave_qscintilla::ctx_menu_run_finished - (bool show_dbg_file, int, QPointer tmp_file, + (int, QPointer tmp_file, QPointer tmp_hist, bool dbg, bool auto_repeat) { emit focus_console_after_command_signal (); @@ -1106,12 +1093,12 @@ // possible lines from commands at a debug prompt must be // taken into consideration. - gui_settings settings; - - settings.setValue (ed_show_dbg_file.settings_key (), show_dbg_file); - if (tmp_file && tmp_file->exists ()) - tmp_file->remove (); + { + tmp_file->remove (); + gui_settings settings; + settings.setValue (ed_run_selection_tmp_file.settings_key (), QString ()); + } if (tmp_hist && tmp_hist->exists ()) tmp_hist->remove (); diff -r 3362e398d702 -r a583e8d66a19 libgui/src/m-editor/octave-qscintilla.h --- a/libgui/src/m-editor/octave-qscintilla.h Sun Apr 28 12:03:16 2024 +0200 +++ b/libgui/src/m-editor/octave-qscintilla.h Sun Apr 28 21:28:00 2024 +0200 @@ -96,7 +96,7 @@ void show_symbol_tooltip_signal (const QPoint&, const QString&); void context_menu_break_condition_signal (int); void context_menu_break_once (int); - void ctx_menu_run_finished_signal (bool, int, QPointer, + void ctx_menu_run_finished_signal (int, QPointer, QPointer, bool, bool); void focus_console_after_command_signal (); @@ -110,7 +110,7 @@ private slots: - void ctx_menu_run_finished (bool, int, QPointer, + void ctx_menu_run_finished (int, QPointer, QPointer, bool, bool); void contextmenu_help (bool);