- 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: 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 Edit/Selection/Code/Refactor menu if no file openning.
- enhancement: Auto hide Project menu if no project 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 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

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

View File

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

View File

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

View File

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