# HG changeset patch # User Torsten Lilge # Date 1622401222 -7200 # Node ID da9c55b3e9fa9d9347983bb556cb1ddc494f8f2a # Parent 82e45c11da7d0f525e530db2dc85b0e37a277d5d fix wring row/col indicator in GUI editor when auto intending (bug #60690) * file-editor-tab.cc (file_editor_tab): connect new edit area signal for updating row/col indicator; (handle_cursor_moved): improve code for detecting requirement for smart indenting, update row/col indicator before smart indenting but store m_line before; (update_rowcol_indicator): moved updating row/col indicator and storing old line and col into new function * file-editor-tab.h: new function update_rowcol_indicator * octave-qscintilla.cc (setCursorPosition) overwrite base virtual function for adding an update of the row/col indicator via emitting the new signal update_rowcol_indicator_signal * octave-qscintilla.h: overloaded setCursorPosition, new signal update_rowcol_indicator_signal diff -r 82e45c11da7d -r da9c55b3e9fa libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Sun May 30 14:42:36 2021 +0200 +++ b/libgui/src/m-editor/file-editor-tab.cc Sun May 30 21:00:22 2021 +0200 @@ -146,6 +146,9 @@ connect (m_edit_area, &octave_qscintilla::context_menu_edit_signal, this, &file_editor_tab::handle_context_menu_edit); + connect (m_edit_area, &octave_qscintilla::update_rowcol_indicator_signal, + this, &file_editor_tab::update_rowcol_indicator); + // create statusbar for row/col indicator and eol mode m_status_bar = new QStatusBar (this); @@ -3044,20 +3047,25 @@ emit autoc_closed (); // Tell editor about closed list } - // Lines changed? Take care of indentation - if (m_lines_changed) // cursor moved and lines have changed - { - m_lines_changed = false; - if (m_is_octave_file && line == m_line+1 && col < m_col) - { - // Obviously, we have a newline here - if (m_smart_indent || m_auto_endif) - m_edit_area->smart_indent (m_smart_indent, m_auto_endif, - m_line, m_ind_char_width); - } - } + // Lines changed? Take care of indentation! + bool do_smart_indent = m_lines_changed && m_is_octave_file + && (line == m_line+1) && (col < m_col) + && (m_smart_indent || m_auto_endif); + m_lines_changed = false; // Update line and column indicator in the status bar + int o_line = m_line; + update_rowcol_indicator (line, col); + + // Do smart indent after update of line indicator for having + // consistent indicator data + if (do_smart_indent) + m_edit_area->smart_indent (m_smart_indent, m_auto_endif, + o_line, m_ind_char_width); + } + + void file_editor_tab::update_rowcol_indicator (int line, int col) + { m_line = line; m_col = col; m_row_indicator->setNum (line+1); diff -r 82e45c11da7d -r da9c55b3e9fa libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Sun May 30 14:42:36 2021 +0200 +++ b/libgui/src/m-editor/file-editor-tab.h Sun May 30 21:00:22 2021 +0200 @@ -204,7 +204,7 @@ void handle_request_remove_breakpoint (int line); void update_breakpoints_handler (const octave_value_list& argout); - + void update_rowcol_indicator (int line, int col); void update_lexer_settings (bool update_apis_only = false); private slots: diff -r 82e45c11da7d -r da9c55b3e9fa libgui/src/m-editor/octave-qscintilla.cc --- a/libgui/src/m-editor/octave-qscintilla.cc Sun May 30 14:42:36 2021 +0200 +++ b/libgui/src/m-editor/octave-qscintilla.cc Sun May 30 21:00:22 2021 +0200 @@ -231,6 +231,12 @@ emit status_update (isUndoAvailable (), isRedoAvailable ()); } + void octave_qscintilla::setCursorPosition (int line, int col) + { + QsciScintilla::setCursorPosition (line, col); + emit update_rowcol_indicator_signal (line, col); + } + void octave_qscintilla::set_selection_marker_color (const QColor& c) { QColor ic = c; diff -r 82e45c11da7d -r da9c55b3e9fa libgui/src/m-editor/octave-qscintilla.h --- a/libgui/src/m-editor/octave-qscintilla.h Sun May 30 14:42:36 2021 +0200 +++ b/libgui/src/m-editor/octave-qscintilla.h Sun May 30 21:00:22 2021 +0200 @@ -58,6 +58,7 @@ }; virtual void contextMenuEvent (QContextMenuEvent *e); + virtual void setCursorPosition (int line, int col); void context_help_doc (bool); void context_edit (void); @@ -86,6 +87,7 @@ signals: + void update_rowcol_indicator_signal (int line, int col); void execute_command_in_terminal_signal (const QString&); void create_context_menu_signal (QMenu*); void context_menu_edit_signal (const QString&);