# HG changeset patch # User Markus Meisinger # Date 1590087749 -7200 # Node ID 668b38ab90f754c2e7f575fe5b03ae547be23eb7 # Parent 75c87b15bceede6ee56d590872da5027ebce7b1a fix jumping vertical scrollbar when file is saved in editor (bug #58418) * file-editor-tab.cc: save the vertical scroll position before the trailing spaces are trimmed, and restore the position after the trimmed data is put back into the m_edit_area diff -r 75c87b15bcee -r 668b38ab90f7 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Sun May 24 10:41:11 2020 +0200 +++ b/libgui/src/m-editor/file-editor-tab.cc Thu May 21 21:02:29 2020 +0200 @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -2294,7 +2295,8 @@ if (settings->value (ed_rm_trailing_spaces).toBool ()) { int line, col; - m_edit_area->getCursorPosition (&line,&col); + m_edit_area->getCursorPosition (&line, &col); + const int vscroll_pos = m_edit_area->verticalScrollBar()->value(); QString eol = eol_string (); QString edit_text = m_edit_area->text (); @@ -2304,7 +2306,8 @@ edit_text.chop (edit_text.length () - idx - 1); // Last line m_edit_area->setText (edit_text); - m_edit_area->setCursorPosition (line,col); + m_edit_area->setCursorPosition (line, col); + m_edit_area->verticalScrollBar()->setValue(vscroll_pos); } // Save the file