diff --git a/NEWS.md b/NEWS.md index 5e6078df..36b1b4c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,11 +3,14 @@ Red Panda C++ Version 2.15 - fix: Static class members is not correctly recognized as static. - fix: Function with reference type return value is not correctly parsed. - enhancement: Add descriptions for x86 registers in the cpu info dialog. - - fix: Search dialog shouldn't have "confirm when replace". + - fix: Search dialog shouldn't have "prompt when replace". - change: Default value for the debugger debugger panel "memory view's columns" is changed from 8 to 16. - change: Default value for the debugger debugger panel "memory view's rows" is changed from 8 to 16. - enhancement: Display hex value as ascii chars in the debugger panel memory view tab. - fix: Word on the last line's end can't be searched. + - enhancement: Auto close other search/replace dialogs when start to search/replace. + - change: Remove "prompt when replace" in the replace. + - fix: Search/replace with regex is not correctly handled. Red Panda C++ Version 2.14 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 753fb525..49208423 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1058,6 +1058,16 @@ int MainWindow::calIconSize(const QString &fontName, int fontPointSize) return metrics.ascent(); } +void MainWindow::hideAllSearchDialogs() +{ + if (mReplaceDialog) + mReplaceDialog->hide(); + if (mSearchDialog) + mSearchDialog->hide(); + if (mSearchInFilesDialog) + mSearchInFilesDialog->hide(); +} + void MainWindow::prepareSearchDialog() { if (!mSearchDialog) @@ -1070,6 +1080,13 @@ void MainWindow::prepareReplaceDialog() mReplaceDialog = new ReplaceDialog(this); } +void MainWindow::prepareSearchInFilesDialog() +{ + if (mSearchInFilesDialog==nullptr) { + mSearchInFilesDialog = new SearchInFileDialog(this); + } +} + void MainWindow::updateAppTitle() { Editor *e = mEditorList->getEditor(); @@ -6270,15 +6287,15 @@ void MainWindow::on_actionFind_triggered() if (!e) return; QString s = e->wordAtCursor(); + hideAllSearchDialogs(); prepareSearchDialog(); mSearchDialog->find(s); } void MainWindow::on_actionFind_in_files_triggered() { - if (mSearchInFilesDialog==nullptr) { - mSearchInFilesDialog = new SearchInFileDialog(this); - } + hideAllSearchDialogs(); + prepareSearchInFilesDialog(); Editor *e = mEditorList->getEditor(); if (e) { QString s = e->wordAtCursor(); @@ -6295,6 +6312,7 @@ void MainWindow::on_actionReplace_triggered() return; QString s = e->wordAtCursor(); + hideAllSearchDialogs(); prepareReplaceDialog(); mReplaceDialog->replace(s); } @@ -6341,9 +6359,7 @@ void MainWindow::on_cbSearchHistory_currentIndexChanged(int index) void MainWindow::on_btnSearchAgain_clicked() { - if (mSearchInFilesDialog==nullptr) { - mSearchInFilesDialog = new SearchInFileDialog(this); - } + hideAllSearchDialogs(); PSearchResults results=mSearchResultModel.currentResults(); if (!results) return; diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index d1aa2d8b..57ff13e9 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -274,8 +274,10 @@ public slots: private: int calIconSize(const QString &fontName, int fontPointSize); + void hideAllSearchDialogs(); void prepareSearchDialog(); void prepareReplaceDialog(); + void prepareSearchInFilesDialog(); void prepareProjectForCompile(); void closeProject(bool refreshEditor); void updateProjectView(); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 7418e50e..4affc7e2 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -965,7 +965,6 @@ - 50 false diff --git a/RedPandaIDE/widgets/replacedialog.ui b/RedPandaIDE/widgets/replacedialog.ui index c7555a81..8fe2733c 100644 --- a/RedPandaIDE/widgets/replacedialog.ui +++ b/RedPandaIDE/widgets/replacedialog.ui @@ -7,7 +7,7 @@ 0 0 512 - 242 + 308 @@ -196,12 +196,18 @@ 7 - - - - Whole words only + + + + Qt::Vertical - + + + 20 + 40 + + + @@ -213,6 +219,26 @@ + + + + Case Sensitive + + + + + + + + 0 + 0 + + + + Regular Expression + + + @@ -229,49 +255,13 @@ - - - - - 0 - 0 - - + + - Regular Expression + Whole words only - - - - Prompt on replace - - - true - - - - - - - Case Sensitive - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 44c9565a..89e1e9d3 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -5121,10 +5121,10 @@ int QSynEdit::searchReplace(const QString &sSearch, const QString &sReplace, Sea ptCurrent = ptStart; } } else { - ptStart.ch = 1; + ptStart.ch = 0; ptStart.line = 1; ptEnd.line = mDocument->count(); - ptEnd.ch = mDocument->getLine(ptEnd.line - 1).length(); + ptEnd.ch = mDocument->getLine(ptEnd.line - 1).length()+1; if (bFromCursor) { if (bBackward) ptEnd = caretXY(); @@ -5173,12 +5173,19 @@ int QSynEdit::searchReplace(const QString &sSearch, const QString &sReplace, Sea // Is the search result entirely in the search range? bool isInValidSearchRange = true; int first = nFound; - int last = nFound + nSearchLen -1; + int last = nFound + nSearchLen; if ((mActiveSelectionMode == SelectionMode::Normal) || !sOptions.testFlag(ssoSelectedOnly)) { - if (((ptCurrent.line == ptStart.line) && (first < ptStart.ch)) || - ((ptCurrent.line == ptEnd.line) && (last > ptEnd.ch))) +// qDebug()< ptEnd.ch))) { + isInValidSearchRange = false; + } } else if (mActiveSelectionMode == SelectionMode::Column) { // solves bug in search/replace when smColumn mode active and no selection isInValidSearchRange = ((first >= ptStart.ch) && (last <= ptEnd.ch)) @@ -5249,15 +5256,17 @@ int QSynEdit::searchReplace(const QString &sSearch, const QString &sReplace, Sea break; //search start from cursor, search has finished but no result founds bFromCursor = false; - ptStart.ch = 1; + ptStart.ch = 0; ptStart.line = 1; ptEnd.line = mDocument->count(); - ptEnd.ch = mDocument->getLine(ptEnd.line - 1).length(); + ptEnd.ch = mDocument->getLine(ptEnd.line - 1).length()+1; if (bBackward) { ptStart = originCaretXY; + ptEnd.ch++; ptCurrent = ptEnd; } else { ptEnd= originCaretXY; + ptStart.ch--; ptCurrent = ptStart; } } diff --git a/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp b/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp index 1618b37e..a9c2765c 100644 --- a/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp +++ b/libs/qsynedit/qsynedit/searcher/regexsearcher.cpp @@ -53,8 +53,6 @@ int RegexSearcher::findAll(const QString &text) QRegularExpressionMatchIterator it = mRegex.globalMatch(text); while (it.hasNext()) { QRegularExpressionMatch match = it.next(); - if (match.capturedLength()==0) - continue; mLengths.append(match.capturedLength()); mResults.append(match.capturedStart()); }