Skip to content

Commit

Permalink
Mantis#2467
Browse files Browse the repository at this point in the history
  • Loading branch information
trexinc committed Jun 19, 2016
1 parent 8989f14 commit 4482f4a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions far/PluginA.cpp
Expand Up @@ -2590,9 +2590,9 @@ static int WINAPI FarMenuFnA(intptr_t PluginNumber, int X, int Y, int MaxHeight,
if (BreakKeysCount)
{
NewBreakKeys.resize(BreakKeysCount);
std::transform(BreakKeys, BreakKeys + BreakKeysCount, NewBreakKeys.begin(), [&](int i)
std::transform(BreakKeys, BreakKeys + BreakKeysCount, NewBreakKeys.begin(), [](int i)
{
VALUE_TYPE(NewBreakKeys) NewItem;
FarKey NewItem;
NewItem.VirtualKeyCode = i & 0xffff;
NewItem.ControlKeyState = 0;
DWORD ItemFlags = i >> 16;
Expand Down
6 changes: 6 additions & 0 deletions far/changelog
@@ -1,3 +1,9 @@
t-rex 19.06.2016 21:15:20 +0200 - build 4717

1. Mantis#2467: Застряёт регэксп поиск с заменой в редакторе

2. Не собиралось почему то в VC2015 update 3 (вроде баг в последнем)

drkns 18.06.2016 18:09:29 +0200 - build 4716

1. Уточнение 4715.
Expand Down
38 changes: 23 additions & 15 deletions far/editor.cpp
Expand Up @@ -3618,7 +3618,7 @@ BOOL Editor::Search(int Next)

int at_end = EdOpt.SearchCursorAtEnd ? SearchLength : 0;

int Skip=FALSE;
bool Skip=false, ZeroLength=false;

// Отступим на четверть и проверим на перекрытие диалогом замены
int FromTop=(ScrY-2)/4;
Expand Down Expand Up @@ -3649,35 +3649,38 @@ BOOL Editor::Search(int Next)
if (!ReplaceAll)
{
Show();
SHORT CurX,CurY;
GetCursorPos(CurX,CurY);
SHORT CurX, CurY;
GetCursorPos(CurX, CurY);
int lpos = CurPtr->LeftPos;
int endX = CurPtr->RealPosToTab(CurPtr->TabPosToReal(lpos + CurX) + SearchLength - 1) - lpos;
ChangeBlockColor(CurX,CurY, endX,CurY, colors::PaletteColorToFarColor(COL_EDITORSELECTEDTEXT));
string strQSearchStr(CurPtr->GetString().data() + CurPtr->GetCurPos(),SearchLength), strQReplaceStr=strReplaceStrCurrent;
ChangeBlockColor(CurX, CurY, endX, CurY, colors::PaletteColorToFarColor(COL_EDITORSELECTEDTEXT));
string strQSearchStr(CurPtr->GetString().data() + CurPtr->GetCurPos(), SearchLength), strQReplaceStr = strReplaceStrCurrent;

// do not use InsertQuote, AI is not suitable here
strQSearchStr.insert(0, 1, L'"');
strQSearchStr.push_back(L'"');
strQReplaceStr.insert(0, 1, L'"');
strQReplaceStr.push_back(L'"');

std::unique_ptr<PreRedrawItem> pitem(PreRedrawStack().empty()? nullptr : PreRedrawStack().pop());
if (!SearchLength && !strReplaceStrCurrent.length())
ZeroLength = true;

MsgCode=Message(0,4,MSG(MEditReplaceTitle),MSG(MEditAskReplace),
strQSearchStr.data(),MSG(MEditAskReplaceWith),strQReplaceStr.data(),
MSG(MEditReplace),MSG(MEditReplaceAll),MSG(MEditSkip),MSG(MEditCancel));
std::unique_ptr<PreRedrawItem> pitem(PreRedrawStack().empty() ? nullptr : PreRedrawStack().pop());

MsgCode = Message(0, 4, MSG(MEditReplaceTitle), MSG(MEditAskReplace),
strQSearchStr.data(), MSG(MEditAskReplaceWith), strQReplaceStr.data(),
MSG(MEditReplace), MSG(MEditReplaceAll), MSG(MEditSkip), MSG(MEditCancel));
if (pitem)
{
PreRedrawStack().push(std::move(pitem));
}
if (MsgCode==1)
if (MsgCode == 1)
ReplaceAll = true;

if (MsgCode==2)
Skip=TRUE;
if (MsgCode == 2)
Skip = true;

if (MsgCode<0 || MsgCode==3)
if (MsgCode < 0 || MsgCode == 3)
{
UserBreak = true;
break;
Expand Down Expand Up @@ -3798,9 +3801,14 @@ BOOL Editor::Search(int Next)
break;

CurPos = m_it_CurLine->GetCurPos();
CurPos += (Skip && !ReverseSearch ? 1:0);
if (!Skip && ReverseSearch)
if ((Skip || ZeroLength) && !ReverseSearch)
{
CurPos++;
}
if (!(Skip || ZeroLength) && ReverseSearch)
{
(m_it_CurLine = CurPtr = m_FoundLine)->SetCurPos(CurPos = m_FoundPos);
}
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4716)m4_dnl
m4_define(BUILD,4717)m4_dnl

0 comments on commit 4482f4a

Please sign in to comment.