- enhancement: Restore line position after file is modified outside and reloaded.

This commit is contained in:
Roy Qu 2024-03-22 20:32:48 +08:00
parent e291a2e2fb
commit 8307f1b38f
2 changed files with 5 additions and 0 deletions

View File

@ -78,6 +78,7 @@ Red Panda C++ Version 2.27
- fix: History not correctly loaded with up/down arrow key in the debug console. - fix: History not correctly loaded with up/down arrow key in the debug console.
- enhancement: Improve lambda support. - enhancement: Improve lambda support.
- enhancement: Show type completion hint after "constexpr"/"extern"/"static"/"consteval"/"constinit"/"const"/"volatile" etc. - 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 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -5482,7 +5482,11 @@ void MainWindow::onFileChanged(const QString &path)
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes|QMessageBox::No,
QMessageBox::No) == QMessageBox::Yes) { QMessageBox::No) == QMessageBox::Yes) {
try { try {
int topLine = e->topLine();
QSynedit::BufferCoord caretPos = e->caretXY();
e->loadFile(); e->loadFile();
e->setCaretPositionAndActivate(caretPos.line,1);
e->setTopLine(topLine);
} catch(FileError e) { } catch(FileError e) {
QMessageBox::critical(this,tr("Error"),e.reason()); QMessageBox::critical(this,tr("Error"),e.reason());
} }