changeset 28361:5c39263f1d70

update cursor position if within trailing spaces removed while saving * file-editor-tab.cc (do_save_file): compare old column with new file and update column if required before restoring the position
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 22 May 2020 22:54:55 +0200
parents 668b38ab90f7
children c54f2ba6ea72
files libgui/src/m-editor/file-editor-tab.cc
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Thu May 21 21:02:29 2020 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Fri May 22 22:54:55 2020 +0200
@@ -2306,6 +2306,9 @@
         edit_text.chop (edit_text.length () - idx - 1); // Last line
 
         m_edit_area->setText (edit_text);
+        const int col_max = m_edit_area->text (line).length () - 1;
+        if (col_max < col)
+          col = col_max;
         m_edit_area->setCursorPosition (line, col);
         m_edit_area->verticalScrollBar()->setValue(vscroll_pos);
       }