@@ -3917,54 +3917,47 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3917
3917
boost::match_flag_type flags = boost::match_default | boost::format_all;
3918
3918
if (!bDotMatchesNewline)
3919
3919
flags |= boost::match_not_dot_newline;
3920
- long prevLineStart = 0 ;
3921
- long prevLineEnd = 0 ;
3922
3920
while (!bCancelled && regex_search (start, end, whatC, expression, flags))
3923
3921
{
3924
3922
if (whatC[0 ].matched )
3925
3923
{
3926
3924
nFound++;
3927
3925
if (m_bNotSearch)
3928
3926
break ;
3929
- long posMatch = static_cast <long >(whatC[0 ].first - textFile.GetFileString ().begin ());
3930
- long lineStart = textFile.LineFromPosition (posMatch);
3931
- long lineEnd = textFile.LineFromPosition (static_cast <long >(whatC[0 ].second - textFile.GetFileString ().begin ()));
3932
- if ((lineStart != prevLineStart) || (lineEnd != prevLineEnd))
3927
+ long posMatch = static_cast <long >(whatC[0 ].first - textFile.GetFileString ().begin ());
3928
+ long lineStart = textFile.LineFromPosition (posMatch);
3929
+ long lineEnd = textFile.LineFromPosition (static_cast <long >(whatC[0 ].second - textFile.GetFileString ().begin ()));
3930
+ long lenLineEncodingPre = 0 ;
3931
+ long colMatch = columnFromPosition (textFile.GetFileString (), posMatch, &lenLineEncodingPre);
3932
+ long lenMatch = static_cast <long >(whatC[0 ].length ());
3933
+ for (long l = lineStart; l <= lineEnd; ++l)
3933
3934
{
3934
- long lenLineEncodingPre = 0 ;
3935
- long colMatch = columnFromPosition (textFile.GetFileString (), posMatch, &lenLineEncodingPre);
3936
- long lenMatch = static_cast <long >(whatC[0 ].length ());
3937
- for (long l = lineStart; l <= lineEnd; ++l)
3935
+ auto sLine = textFile.GetLineString (l);
3936
+ long lenLineMatch = static_cast <long >(sLine .length ()) - colMatch;
3937
+ if (lenMatch < lenLineMatch)
3938
3938
{
3939
- auto sLine = textFile.GetLineString (l);
3940
- long lenLineMatch = static_cast <long >(sLine .length ()) - colMatch;
3941
- if (lenMatch < lenLineMatch)
3942
- {
3943
- lenLineMatch = lenMatch;
3944
- }
3945
- sInfo .matchLinesNumbers .push_back (l);
3946
- sInfo .matchMovesNumbers .push_back (colMatch);
3947
- if (m_bCaptureSearch)
3948
- {
3949
- auto out = whatC.format (m_replaceString, flags);
3950
- sInfo .matchLines .push_back (std::move (out));
3951
- sInfo .matchLengths .push_back (static_cast <long >(out.length ()));
3952
- }
3953
- else
3954
- {
3955
- sInfo .matchLines .push_back (std::move (sLine ));
3956
- sInfo .matchLengths .push_back (lenLineMatch);
3957
- }
3958
- if (lenMatch > lenLineMatch)
3959
- {
3960
- colMatch = 1 ;
3961
- lenMatch -= lenLineMatch + lenLineEncodingPre;
3962
- }
3939
+ lenLineMatch = lenMatch;
3940
+ }
3941
+ sInfo .matchLinesNumbers .push_back (l);
3942
+ sInfo .matchMovesNumbers .push_back (colMatch);
3943
+ if (m_bCaptureSearch)
3944
+ {
3945
+ auto out = whatC.format (m_replaceString, flags);
3946
+ sInfo .matchLines .push_back (std::move (out));
3947
+ sInfo .matchLengths .push_back (static_cast <long >(out.length ()));
3948
+ }
3949
+ else
3950
+ {
3951
+ sInfo .matchLines .push_back (std::move (sLine ));
3952
+ sInfo .matchLengths .push_back (lenLineMatch);
3953
+ }
3954
+ if (lenMatch > lenLineMatch)
3955
+ {
3956
+ colMatch = 1 ;
3957
+ lenMatch -= lenLineMatch + lenLineEncodingPre;
3963
3958
}
3964
3959
}
3965
3960
++sInfo .matchCount ;
3966
- prevLineStart = lineStart;
3967
- prevLineEnd = lineEnd;
3968
3961
}
3969
3962
// update search position:
3970
3963
if (start == whatC[0 ].second )
@@ -3992,12 +3985,12 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3992
3985
nFound++;
3993
3986
if (m_bNotSearch)
3994
3987
break ;
3995
- long posMatch = static_cast <long >(whatC[0 ].first - textFile.GetFileString ().begin ());
3996
- long lineStart = textFile.LineFromPosition (posMatch);
3997
- long lineEnd = textFile.LineFromPosition (static_cast <long >(whatC[0 ].second - textFile.GetFileString ().begin ()));
3988
+ long posMatch = static_cast <long >(whatC[0 ].first - textFile.GetFileString ().begin ());
3989
+ long lineStart = textFile.LineFromPosition (posMatch);
3990
+ long lineEnd = textFile.LineFromPosition (static_cast <long >(whatC[0 ].second - textFile.GetFileString ().begin ()));
3998
3991
long lenLineEncodingPre = 0 ;
3999
- long colMatch = columnFromPosition (textFile.GetFileString (), posMatch, &lenLineEncodingPre);
4000
- long lenMatch = static_cast <long >(whatC[0 ].length ());
3992
+ long colMatch = columnFromPosition (textFile.GetFileString (), posMatch, &lenLineEncodingPre);
3993
+ long lenMatch = static_cast <long >(whatC[0 ].length ());
4001
3994
if (m_bCaptureSearch)
4002
3995
{
4003
3996
auto out = whatC.format (m_replaceString, flags);
@@ -4008,31 +4001,26 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4008
4001
}
4009
4002
else
4010
4003
{
4011
- if ((lineStart != prevLineStart) || (lineEnd != prevLineEnd) )
4004
+ for ( long l = lineStart; l <= lineEnd; ++l )
4012
4005
{
4013
- for (long l = lineStart; l <= lineEnd; ++l)
4006
+ auto sLine = textFile.GetLineString (l);
4007
+ long lenLineMatch = static_cast <long >(sLine .length ()) - colMatch;
4008
+ if (lenMatch < lenLineMatch)
4014
4009
{
4015
- auto sLine = textFile.GetLineString (l);
4016
- long lenLineMatch = static_cast <long >(sLine .length ()) - colMatch;
4017
- if (lenMatch < lenLineMatch)
4018
- {
4019
- lenLineMatch = lenMatch;
4020
- }
4021
- sInfo .matchLines .push_back (sLine );
4022
- sInfo .matchLinesNumbers .push_back (l);
4023
- sInfo .matchMovesNumbers .push_back (colMatch);
4024
- sInfo .matchLengths .push_back (lenLineMatch);
4025
- if (lenMatch > lenLineMatch)
4026
- {
4027
- colMatch = 1 ;
4028
- lenMatch -= lenLineMatch + lenLineEncodingPre;
4029
- }
4010
+ lenLineMatch = lenMatch;
4011
+ }
4012
+ sInfo .matchLines .push_back (sLine );
4013
+ sInfo .matchLinesNumbers .push_back (l);
4014
+ sInfo .matchMovesNumbers .push_back (colMatch);
4015
+ sInfo .matchLengths .push_back (lenLineMatch);
4016
+ if (lenMatch > lenLineMatch)
4017
+ {
4018
+ colMatch = 1 ;
4019
+ lenMatch -= lenLineMatch + lenLineEncodingPre;
4030
4020
}
4031
4021
}
4032
4022
}
4033
4023
++sInfo .matchCount ;
4034
- prevLineStart = lineStart;
4035
- prevLineEnd = lineEnd;
4036
4024
}
4037
4025
// update search position:
4038
4026
if (start == whatC[0 ].second )
0 commit comments