diff --git a/NEWS.md b/NEWS.md index ba764a35..421c419a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -78,6 +78,7 @@ Red Panda C++ Version 2.27 - fix: History not correctly loaded with up/down arrow key in the debug console. - enhancement: Improve lambda support. - enhancement: Show type completion hint after "constexpr"/"extern"/"static"/"consteval"/"constinit"/"const"/"volatile" etc. + - enhancement: Restore line position after file is modified outside and reloaded. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 595c0bf9..16948729 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -5482,7 +5482,11 @@ void MainWindow::onFileChanged(const QString &path) QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { try { + int topLine = e->topLine(); + QSynedit::BufferCoord caretPos = e->caretXY(); e->loadFile(); + e->setCaretPositionAndActivate(caretPos.line,1); + e->setTopLine(topLine); } catch(FileError e) { QMessageBox::critical(this,tr("Error"),e.reason()); }