- 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.
This commit is contained in:
Roy Qu 2023-02-26 08:31:13 +08:00
parent 12983f5ae0
commit 511b6c679b
7 changed files with 79 additions and 62 deletions

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -965,7 +965,6 @@
<widget class="IssuesTable" name="tableIssues">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>512</width>
<height>242</height>
<height>308</height>
</rect>
</property>
<property name="windowTitle">
@ -196,12 +196,18 @@
<property name="bottomMargin">
<number>7</number>
</property>
<item row="1" column="0">
<widget class="QCheckBox" name="chkWholeWord">
<property name="text">
<string>Whole words only</string>
<item row="4" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkWrapAround">
@ -213,6 +219,26 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkCaseSensetive">
<property name="text">
<string>Case Sensitive</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkRegExp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Regular Expression</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="txtRegExpHelp">
<property name="sizePolicy">
@ -229,49 +255,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkRegExp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="1" column="0">
<widget class="QCheckBox" name="chkWholeWord">
<property name="text">
<string>Regular Expression</string>
<string>Whole words only</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkPrompt">
<property name="text">
<string>Prompt on replace</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkCaseSensetive">
<property name="text">
<string>Case Sensitive</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

View File

@ -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()<<ptStart.line<<ptStart.ch<<ptEnd.line<<ptEnd.ch<<ptCurrent.line<<first<<last;
if ((nSearchLen==0) &&
(((ptCurrent.line == ptStart.line) && (first == ptStart.ch) && !bBackward)
|| ((ptCurrent.line == ptEnd.line) && (last == ptEnd.ch) && bBackward))
) {
isInValidSearchRange = false;
} else if (((ptCurrent.line == ptStart.line) && (first < ptStart.ch)) ||
((ptCurrent.line == ptEnd.line) && (last > 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;
}
}

View File

@ -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());
}