@@ -3835,26 +3835,17 @@ bool CSearchDlg::MatchPath(LPCTSTR pathBuf) const
3835
3835
return bPattern;
3836
3836
}
3837
3837
3838
- static long columnFromPosition (const std::wstring& textContent, long pos, long * lenLineEncodingPre )
3838
+ static long columnFromPosition (const std::wstring& textContent, long pos)
3839
3839
{
3840
- *lenLineEncodingPre = 0 ;
3841
- if (pos == 0 )
3842
- {
3843
- return 1 ;
3844
- }
3845
-
3846
3840
long i = pos;
3847
3841
while (i > 0 && textContent[i] != L' \n ' && textContent[i] != L' \r ' )
3848
3842
{
3849
3843
--i;
3850
3844
}
3851
- if (i >= 2 && textContent[i] == L ' \n ' && textContent[i - 1 ] == L ' \r ' )
3845
+ if (pos == i )
3852
3846
{
3853
- *lenLineEncodingPre = 2 ;
3854
- }
3855
- else if (i > 0 )
3856
- {
3857
- *lenLineEncodingPre = 1 ;
3847
+ // first/empty line starting
3848
+ return 1 ;
3858
3849
}
3859
3850
return pos - i;
3860
3851
}
@@ -3941,13 +3932,12 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3941
3932
long posMatch = static_cast <long >(whatC[0 ].first - textFile.GetFileString ().begin ());
3942
3933
long lineStart = textFile.LineFromPosition (posMatch);
3943
3934
long lineEnd = textFile.LineFromPosition (static_cast <long >(whatC[0 ].second - textFile.GetFileString ().begin ()));
3944
- long lenLineEncodingPre = 0 ;
3945
- long colMatch = columnFromPosition (textFile.GetFileString (), posMatch, &lenLineEncodingPre);
3935
+ long colMatch = columnFromPosition (textFile.GetFileString (), posMatch);
3946
3936
long lenMatch = static_cast <long >(whatC[0 ].length ());
3947
3937
for (long l = lineStart; l <= lineEnd; ++l)
3948
3938
{
3949
3939
auto sLine = textFile.GetLineString (l);
3950
- long lenLineMatch = static_cast <long >(sLine .length ()) - colMatch;
3940
+ long lenLineMatch = static_cast <long >(sLine .length ()) - colMatch + 1 ;
3951
3941
if (lenMatch < lenLineMatch)
3952
3942
{
3953
3943
lenLineMatch = lenMatch;
@@ -3968,7 +3958,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3968
3958
if (lenMatch > lenLineMatch)
3969
3959
{
3970
3960
colMatch = 1 ;
3971
- lenMatch -= lenLineMatch + lenLineEncodingPre ;
3961
+ lenMatch -= lenLineMatch;
3972
3962
}
3973
3963
}
3974
3964
++sInfo .matchCount ;
@@ -4002,8 +3992,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4002
3992
long posMatch = static_cast <long >(whatC[0 ].first - textFile.GetFileString ().begin ());
4003
3993
long lineStart = textFile.LineFromPosition (posMatch);
4004
3994
long lineEnd = textFile.LineFromPosition (static_cast <long >(whatC[0 ].second - textFile.GetFileString ().begin ()));
4005
- long lenLineEncodingPre = 0 ;
4006
- long colMatch = columnFromPosition (textFile.GetFileString (), posMatch, &lenLineEncodingPre);
3995
+ long colMatch = columnFromPosition (textFile.GetFileString (), posMatch);
4007
3996
long lenMatch = static_cast <long >(whatC[0 ].length ());
4008
3997
if (m_bCaptureSearch)
4009
3998
{
@@ -4030,7 +4019,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4030
4019
if (lenMatch > lenLineMatch)
4031
4020
{
4032
4021
colMatch = 1 ;
4033
- lenMatch -= lenLineMatch + lenLineEncodingPre ;
4022
+ lenMatch -= lenLineMatch;
4034
4023
}
4035
4024
}
4036
4025
}
0 commit comments