Mercurial > octave
changeset 28274:667bf684bb29 stable
fix contjnued lines when executing selected editor text (bug #58323)
* octave-qscintilla.cc (contextmenu_run): check for continuation marker
and keep continued lines in the tmp file, which is evaluated later,
together
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Fri, 08 May 2020 19:59:08 +0200 |
parents | 86625d488314 |
children | efa916abcbdd |
files | libgui/src/m-editor/octave-qscintilla.cc |
diffstat | 1 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc Fri May 08 00:55:02 2020 -0400 +++ b/libgui/src/m-editor/octave-qscintilla.cc Fri May 08 19:59:08 2020 +0200 @@ -852,10 +852,14 @@ // Split contents into single lines and complete commands QStringList lines = selectedText ().split (QRegExp ("[\r\n]"), QString::SkipEmptyParts); + QString line_code_tmp; + bool is_contd_line; + QRegExp contd_line ("\\.\\.\\.\\s*$"); for (int i = 0; i < lines.count (); i++) { QString line = lines.at (i); + is_contd_line = line.contains (contd_line); QString line_escaped = line; line_escaped.replace (QString ("'"), QString ("''")); QString line_history = line; @@ -875,6 +879,20 @@ next_bp_quiet_reset = "__db_next_breakpoint_quiet__(false);\n"; } + // Handle continued lines + line_code_tmp = line_code_tmp + line; + QString line_code; + if (is_contd_line) + { + line_code_tmp = line_code_tmp + "\n"; // Next line will be added + line_code = ""; // No code by now + } + else + { + line_code = line_code_tmp + "\n"; // Code is ready + line_code_tmp = ""; // No code to be cont'd + } + // Add codeline together with call to echo/history function to tmp // %1 : function name for displaying and adding to history // %2 : line number @@ -883,14 +901,14 @@ // %5 : command line (eval) code += QString ("%1 (%2, '%3', '%4');\n" + next_bp_quiet - + "%5\n" + + line_code + next_bp_quiet_reset + "\n") .arg (tmp_script_name) .arg (i) .arg (line_escaped) - .arg (line_history) - .arg (line); + .arg (line_history); + } code += QString ("munlock (\"%1\"); clear %1;\n").arg (tmp_script_name); @@ -995,9 +1013,9 @@ resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); settings->setValue (ed_show_dbg_file.key, show_dbg_file); - rmgr.remove_tmp_file (tmp_file); - rmgr.remove_tmp_file (tmp_hist); - rmgr.remove_tmp_file (tmp_script); + //rmgr.remove_tmp_file (tmp_file); + //rmgr.remove_tmp_file (tmp_hist); + //rmgr.remove_tmp_file (tmp_script); }