Skip to content

Commit e779261

Browse files
committed
adjust ShowContextMenu for %move%
and move `linePositions` from public into the function
1 parent 3ccaecf commit e779261

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/LineData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
struct LineDataLine
2424
{
2525
DWORD number;
26+
DWORD move;
2627
std::wstring text;
2728
};
2829

src/SearchDlg.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ DWORD WINAPI SearchThreadEntry(LPVOID lpParam);
7878

7979
// ReSharper disable once CppInconsistentNaming
8080
UINT CSearchDlg::m_grepwinStartupmsg = RegisterWindowMessage(L"grepWin_StartupMessage");
81-
std::map<size_t, DWORD> linePositions;
8281

8382
extern ULONGLONG g_startTime;
8483
extern HANDLE hInitProtection;
@@ -2278,7 +2277,10 @@ void CSearchDlg::ShowContextMenu(HWND hWnd, int x, int y)
22782277
data.path = info.filePath;
22792278
LineDataLine dataLine;
22802279
if (static_cast<int>(info.matchLinesNumbers.size()) > subIdx)
2280+
{
22812281
dataLine.number = info.matchLinesNumbers[subIdx];
2282+
dataLine.move = info.matchMovesNumbers[subIdx];
2283+
}
22822284
if (static_cast<int>(info.matchLines.size()) > subIdx)
22832285
dataLine.text = info.matchLines[subIdx];
22842286
data.lines.push_back(dataLine);
@@ -4233,7 +4235,6 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
42334235
{
42344236
if (!bLoadResult && (type != CTextFile::Binary) && !m_bNotSearch)
42354237
{
4236-
linePositions.clear();
42374238
// open the file and set up a vector of all lines
42384239
CAutoFile hFile;
42394240
int retryCounter = 0;
@@ -4247,9 +4248,10 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
42474248
} while (!hFile && retryCounter < 5);
42484249
if (hFile)
42494250
{
4250-
auto fBuf = std::make_unique<char[]>(4096);
4251-
DWORD bytesRead = 0;
4252-
size_t pos = 0;
4251+
std::map<size_t, DWORD> linePositions;
4252+
auto fBuf = std::make_unique<char[]>(4096);
4253+
DWORD bytesRead = 0;
4254+
size_t pos = 0;
42534255
while (ReadFile(hFile, fBuf.get(), 4096, &bytesRead, nullptr))
42544256
{
42554257
if (bytesRead == 0)

src/ShellContextMenu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
342342
wchar_t buf[40] = {0};
343343
swprintf_s(buf, L"%ld", it2->number);
344344
SearchReplace(cmd, L"%line%", buf);
345+
swprintf_s(buf, L"%ld", it2->move);
346+
SearchReplace(cmd, L"%move%", buf);
345347

346348
STARTUPINFO startupInfo;
347349
PROCESS_INFORMATION processInfo;
@@ -365,9 +367,14 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
365367
wchar_t buf[40] = {0};
366368
swprintf_s(buf, L"%ld", it->matchLinesNumbers[0]);
367369
SearchReplace(cmd, L"%line%", buf);
370+
swprintf_s(buf, L"%ld", it->matchMovesNumbers[0]);
371+
SearchReplace(cmd, L"%move%", buf);
368372
}
369373
else
374+
{
370375
SearchReplace(cmd, L"%line%", L"0");
376+
SearchReplace(cmd, L"%move%", L"0");
377+
}
371378

372379
STARTUPINFO startupInfo;
373380
PROCESS_INFORMATION processInfo;

0 commit comments

Comments
 (0)