- enhancement: restore editor position after rename symbol

- enhancement: restore editor position after reformat code
This commit is contained in:
Roy Qu 2022-01-17 12:34:51 +08:00
parent 264cb5ed1c
commit 7602f3e6be
3 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,7 @@
Red Panda C++ Version 0.13.3
- enhancement: restore editor position after rename symbol
- enhancement: restore editor position after reformat code
Red Panda C++ Version 0.13.2 Red Panda C++ Version 0.13.2
- fix: "delete and exit" button in the environtment / folder option page doesn't work correctly - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly
- fix: crash when closing the options dialog under Ubuntu 20.04 LTS ( no memory leak now) - fix: crash when closing the options dialog under Ubuntu 20.04 LTS ( no memory leak now)

View File

@ -4636,7 +4636,13 @@ void MainWindow::on_actionReformat_Code_triggered()
{ {
Editor* e = mEditorList->getEditor(); Editor* e = mEditorList->getEditor();
if (e) { if (e) {
BufferCoord oldXY=e->caretXY();
int topLine = e->topLine();
int leftChar = e->leftChar();
e->reformat(); e->reformat();
e->setTopLine(topLine);
e->setLeftChar(leftChar);
e->setCaretXY(oldXY);
e->activate(); e->activate();
} }
} }
@ -5479,7 +5485,13 @@ void MainWindow::on_actionRename_Symbol_triggered()
//here we must reparse the file in sync, or rename may fail //here we must reparse the file in sync, or rename may fail
parser->parseFile(editor->filename(), editor->inProject(), false, false); parser->parseFile(editor->filename(), editor->inProject(), false, false);
CppRefacter refactor; CppRefacter refactor;
BufferCoord oldXY=editor->caretXY();
int topLine = editor->topLine();
int leftChar = editor->leftChar();
refactor.renameSymbol(editor,oldCaretXY,word,newWord); refactor.renameSymbol(editor,oldCaretXY,word,newWord);
editor->setTopLine(topLine);
editor->setLeftChar(leftChar);
editor->setCaretXY(oldXY);
editor->reparse(); editor->reparse();
} }

View File

@ -7,7 +7,7 @@ SUBDIRS += \
APP_NAME = RedPandaCPP APP_NAME = RedPandaCPP
APP_VERSION = 0.13.2 APP_VERSION = 0.13.3
linux: { linux: {