changeset 26131:22edc076543e

restore line/column when reloading externally changed editor files (bug #54961) * file-editor-tab.cc (load_file): save and restore current line and column if the file to load is the current one
author Torsten <mttl@mailbox.org>
date Sat, 24 Nov 2018 13:03:06 +0100
parents 5b5122fea9e9
children 6f4ca6194983
files libgui/src/m-editor/file-editor-tab.cc
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Fri Nov 23 21:30:53 2018 -0800
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sat Nov 24 13:03:06 2018 +0100
@@ -1737,6 +1737,14 @@
     if (!file.open(QIODevice::ReadOnly))
       return file.errorString ();
 
+    int col = 0, line = 0;
+    if (fileName == _file_name)
+      {
+        // We have to reload the current file, thus get current cursor position
+        line = _line;
+        col = _col;
+      }
+
     QApplication::setOverrideCursor (Qt::WaitCursor);
 
     // read the file binary, decoding later
@@ -1789,6 +1797,8 @@
 
     update_eol_indicator ();
 
+    _edit_area->setCursorPosition (line, col);
+
     // FIXME: (BREAKPOINTS) At this point it would be nice to put any set
     // breakpoints on the margin.  In order to do this, somehow the
     // "dbstatus" command needs to be accessed.  All it would require is a