- fix: correctly reparse modified project files when rename symbol

This commit is contained in:
Roy Qu 2022-03-17 20:28:03 +08:00
parent da05088f40
commit 12edcb22a5
2 changed files with 19 additions and 6 deletions

View File

@ -36,6 +36,7 @@ Red Panda C++ Version 1.0.0
- enhancement: create file in files view - enhancement: create file in files view
- fix: hits in the search view not correctly displayed (overlapped with others) - fix: hits in the search view not correctly displayed (overlapped with others)
- enhancement: auto convert project icon to ico format - enhancement: auto convert project icon to ico format
- fix: correctly reparse modified project files when rename symbol
Red Panda C++ Version 0.14.5 Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong - fix: the "gnu c++ 20" option in compiler set options is wrong

View File

@ -5914,7 +5914,8 @@ void MainWindow::on_actionRename_Symbol_triggered()
if (!editor) if (!editor)
return; return;
editor->beginUpdate(); editor->beginUpdate();
// mClassBrowserModel.beginUpdate(); BufferCoord oldCaretXY = editor->caretXY();
// mClassBrowserModel.beginUpdate();
QCursor oldCursor = editor->cursor(); QCursor oldCursor = editor->cursor();
editor->setCursor(Qt::CursorShape::WaitCursor); editor->setCursor(Qt::CursorShape::WaitCursor);
auto action = finally([oldCursor,editor]{ auto action = finally([oldCursor,editor]{
@ -5934,10 +5935,19 @@ void MainWindow::on_actionRename_Symbol_triggered()
return; return;
} }
BufferCoord oldCaretXY = editor->caretXY();
if (editor->inProject() && mProject) { if (editor->inProject() && mProject) {
mProject->cppParser()->parseFileList(); for (int i=0;i<mEditorList->pageCount();i++) {
Editor * e=(*mEditorList)[i];
if (e->modified()) {
mProject->cppParser()->parseFile(editor->filename(), editor->inProject(), false, false);
}
}
QStringList expression = editor->getExpressionAtPosition(oldCaretXY); QStringList expression = editor->getExpressionAtPosition(oldCaretXY);
if (expression.isEmpty() && oldCaretXY.Char>1) {
BufferCoord coord=oldCaretXY;
coord.Char--;
expression = editor->getExpressionAtPosition(coord);
}
// Find it's definition // Find it's definition
PStatement oldStatement = editor->parser()->findStatementOf( PStatement oldStatement = editor->parser()->findStatementOf(
editor->filename(), editor->filename(),
@ -5975,9 +5985,11 @@ void MainWindow::on_actionRename_Symbol_triggered()
if (word == newWord) if (word == newWord)
return; return;
PCppParser parser = editor->parser(); if (!editor->inProject() && editor->modified() ) {
//here we must reparse the file in sync, or rename may fail PCppParser parser = editor->parser();
parser->parseFile(editor->filename(), editor->inProject(), false, false); //here we must reparse the file in sync, or rename may fail
parser->parseFile(editor->filename(), editor->inProject(), false, false);
}
CppRefacter refactor; CppRefacter refactor;
BufferCoord oldXY=editor->caretXY(); BufferCoord oldXY=editor->caretXY();
int topLine = editor->topLine(); int topLine = editor->topLine();