diff --git a/NEWS.md b/NEWS.md
index 847c99f5..b9640a7c 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -3,6 +3,7 @@ Red Panda C++ Version 1.1.0
- enhancement: mark editor as modified, if the editing file is changed by other applications.
- enhancement: When the editing files is changed by other applications, only show one notification dialog for each file.
- fix: c files added to a project will be compiled as c++ file.
+ - enhancement: restore caret position after batch replace
Red Panda C++ Version 1.0.10
- fix: modify watch doesn't work
diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp
index e3faf21b..e8df72f4 100644
--- a/RedPandaIDE/mainwindow.cpp
+++ b/RedPandaIDE/mainwindow.cpp
@@ -6489,8 +6489,14 @@ void MainWindow::on_btnReplace_clicked()
line.insert(item->start-1, newWord);
contents[item->line-1] = line;
}
+ BufferCoord coord=editor->caretXY();
+ int topLine = editor->topLine();
+ int leftChar = editor->leftChar();
editor->selectAll();
editor->setSelText(contents.join(editor->lineBreak()));
+ editor->setCaretXY(coord);
+ editor->setTopLine(topLine);
+ editor->setLeftChar(leftChar);
}
showSearchReplacePanel(false);
stretchMessagesPanel(false);
diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui
index 7bbcc9bc..ca002bc9 100644
--- a/RedPandaIDE/mainwindow.ui
+++ b/RedPandaIDE/mainwindow.ui
@@ -858,7 +858,7 @@
QTabWidget::South
- 6
+ 3
diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp
index 33f7cf37..6a1fe1bd 100644
--- a/RedPandaIDE/project.cpp
+++ b/RedPandaIDE/project.cpp
@@ -903,6 +903,8 @@ void Project::saveOptions()
ini.SetLongValue("Project","SupportXPThemes", mOptions.supportXPThemes);
ini.SetLongValue("Project","CompilerSet", mOptions.compilerSet);
ini.SetLongValue("Project","CompilerSetType", mOptions.compilerSetType);
+ ini.Delete("Project","CompilerSettings"); // remove old compiler settings
+ ini.Delete("CompilerSettings",nullptr); // remove old compiler settings
foreach (const QString& key, mOptions.compilerOptions.keys()) {
ini.SetValue("CompilerSettings",toByteArray(key),toByteArray(mOptions.compilerOptions.value(key)));
}