- fix: Toggle breakpoint by shortcut may use wrong line.

This commit is contained in:
Roy Qu 2024-04-12 12:54:12 +08:00
parent 30a8205058
commit 87586202dc
5 changed files with 24 additions and 35 deletions

View File

@ -136,6 +136,7 @@ Red Panda C++ Version 2.27
- enhancement: In debug console, Ctrl+C/Ctrl+X/Ctrl+V conflicts with application action.
- enhancement: Auto hide Edit/Selection/Code/Refactor menu if no file openning.
- enhancement: Auto hide Project menu if no project openning.
- fix: Toggle breakpoint by shortcut may use wrong line.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

@ -5149,12 +5149,10 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
);
QMenu menu(this);
QSynedit::BufferCoord p;
mEditorContextMenuPos = pos;
int line;
if (editor->getPositionOfMouse(p)) {
line=p.line;
if (!switchHeaderSourceTarget(editor).isEmpty()) {
menu.addAction(ui->actionSwitchHeaderSource);
menu.addSeparator();
}
@ -6322,16 +6320,6 @@ void MainWindow::on_actionPaste_triggered()
editor->pasteFromClipboard();
editor->activate();
}
} else if (data->hasUrls()) {
QStringList filesToOpen;
foreach (const QUrl& url, data->urls()) {
QString s = url.toLocalFile();
if (!s.isEmpty()) {
filesToOpen.append(s);
}
}
if (!filesToOpen.isEmpty())
openFiles(filesToOpen);
}
}
@ -6949,9 +6937,8 @@ void MainWindow::on_actionPrevious_Editor_triggered()
void MainWindow::on_actionToggle_Breakpoint_triggered()
{
Editor * editor = mEditorList->getEditor();
int line;
if (editor && editor->pointToLine(mEditorContextMenuPos,line))
editor->toggleBreakpoint(line);
if (editor)
editor->toggleBreakpoint(editor->caretY());
}
@ -6973,12 +6960,11 @@ void MainWindow::on_actionClear_all_breakpoints_triggered()
void MainWindow::on_actionBreakpoint_property_triggered()
{
Editor * editor = mEditorList->getEditor();
int line;
if (editor && editor->pointToLine(mEditorContextMenuPos,line)) {
if (editor) {
int line = editor->caretY();
if (editor->hasBreakpoint(line))
editor->modifyBreakpointProperty(line);
}
}
@ -7002,10 +6988,9 @@ void MainWindow::on_actionGoto_Definition_triggered()
void MainWindow::on_actionFind_references_triggered()
{
Editor * editor = mEditorList->getEditor();
QSynedit::BufferCoord pos;
if (editor && editor->pointToCharLine(mEditorContextMenuPos,pos)) {
if (editor) {
CppRefacter refactor;
refactor.findOccurence(editor,pos);
refactor.findOccurence(editor, editor->caretXY());
showSearchPanel(false);
}
}
@ -8587,10 +8572,10 @@ TodoModel *MainWindow::todoModel()
void MainWindow::on_actionAdd_bookmark_triggered()
{
Editor* editor = mEditorList->getEditor();
int line;
if (editor && editor->pointToLine(mEditorContextMenuPos,line)) {
if (editor) {
if (editor->lineCount()<=0)
return;
int line = editor->caretY();
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),
tr("Description:"),QLineEdit::Normal,
editor->lineText(line).trimmed());
@ -8604,8 +8589,8 @@ void MainWindow::on_actionAdd_bookmark_triggered()
void MainWindow::on_actionRemove_Bookmark_triggered()
{
Editor* editor = mEditorList->getEditor();
int line;
if (editor && editor->pointToLine(mEditorContextMenuPos,line)) {
if (editor) {
int line = editor->caretY();
editor->removeBookmark(line);
mBookmarkModel->removeBookmark(editor->filename(),line,editor->inProject());
}
@ -8629,8 +8614,8 @@ void MainWindow::on_tableBookmark_doubleClicked(const QModelIndex &index)
void MainWindow::on_actionModify_Bookmark_Description_triggered()
{
Editor* editor = mEditorList->getEditor();
int line;
if (editor && editor->pointToLine(mEditorContextMenuPos,line)) {
if (editor) {
int line = editor->caretY();
PBookmark bookmark = mBookmarkModel->bookmark(editor->filename(),line);
if (bookmark) {
QString desc = QInputDialog::getText(editor,tr("Bookmark Description"),

View File

@ -932,7 +932,6 @@ private:
bool mClosingAll;
bool mOpenningFiles;
bool mSystemTurnedOff;
QPoint mEditorContextMenuPos;
QTcpServer mTcpServer;
QColor mErrorColor;
CompileIssuesState mCompileIssuesState;

View File

@ -42,17 +42,20 @@ SearchDialog::~SearchDialog()
void SearchDialog::find(const QString &text)
{
mTabBar->setCurrentIndex(mSearchTabIdx);
if (!text.isEmpty())
ui->cbFind->setCurrentText(text);
ui->cbFind->setFocus();
ui->btnNext->setFocus();
show();
}
void SearchDialog::replace(const QString &text)
{
mTabBar->setCurrentIndex(mReplaceTabIdx);
if (!text.isEmpty()) {
ui->cbFind->setCurrentText(text);
ui->cbReplace->setCurrentText(text);
ui->cbFind->setFocus();
}
ui->btnNext->setFocus();
show();
}

View File

@ -54,8 +54,9 @@ SearchInFileDialog::~SearchInFileDialog()
void SearchInFileDialog::findInFiles(const QString &text)
{
if (!text.isEmpty())
ui->cbFind->setCurrentText(text);
ui->cbFind->setFocus();
ui->btnExecute->setFocus();
show();
}