Skip to content

Commit

Permalink
Don't search PATH when activating previous instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 14, 2019
1 parent 6edb85a commit 2b42c80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
13 changes: 1 addition & 12 deletions metapath/src/metapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -3238,23 +3238,12 @@ BOOL ActivatePrevInst(void) {
SetForegroundWindow(hwnd);

if (lpPathArg) {
// Search working directory from second instance, first!
// lpPathArg is at least MAX_PATH+2 bytes
WCHAR tchTmp[MAX_PATH];

ExpandEnvironmentStringsEx(lpPathArg, (DWORD)(GlobalSize(lpPathArg) / sizeof(WCHAR)));

if (PathIsRelative(lpPathArg)) {
WCHAR tchTmp[MAX_PATH];
GetCurrentDirectory(COUNTOF(tchTmp), tchTmp);
PathAppend(tchTmp, lpPathArg);
if (PathFileExists(tchTmp)) {
lstrcpy(lpPathArg, tchTmp);
} else {
if (SearchPath(NULL, lpPathArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) {
lstrcpy(lpPathArg, tchTmp);
}
}
} else if (SearchPath(NULL, lpPathArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) {
lstrcpy(lpPathArg, tchTmp);
}

Expand Down
20 changes: 2 additions & 18 deletions src/Notepad2.c
Original file line number Diff line number Diff line change
Expand Up @@ -7307,18 +7307,13 @@ BOOL ActivatePrevInst(void) {
}

if (flagSingleFileInstance && lpFileArg) {
// Search working directory from second instance, first!
// lpFileArg is at least MAX_PATH+2 bytes
WCHAR tchTmp[MAX_PATH];

ExpandEnvironmentStringsEx(lpFileArg, (DWORD)(NP2HeapSize(lpFileArg) / sizeof(WCHAR)));

if (PathIsRelative(lpFileArg)) {
WCHAR tchTmp[MAX_PATH];
lstrcpyn(tchTmp, g_wchWorkingDirectory, COUNTOF(tchTmp));
PathAppend(tchTmp, lpFileArg);
lstrcpy(lpFileArg, tchTmp);
} else if (SearchPath(NULL, lpFileArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) {
lstrcpy(lpFileArg, tchTmp);
}

GetLongPathNameEx(lpFileArg, MAX_PATH);
Expand Down Expand Up @@ -7413,23 +7408,12 @@ BOOL ActivatePrevInst(void) {
SetForegroundWindow(hwnd);

if (lpFileArg) {
// Search working directory from second instance, first!
// lpFileArg is at least MAX_PATH+2 bytes
WCHAR tchTmp[MAX_PATH];

ExpandEnvironmentStringsEx(lpFileArg, (DWORD)(NP2HeapSize(lpFileArg) / sizeof(WCHAR)));

if (PathIsRelative(lpFileArg)) {
WCHAR tchTmp[MAX_PATH];
lstrcpyn(tchTmp, g_wchWorkingDirectory, COUNTOF(tchTmp));
PathAppend(tchTmp, lpFileArg);
if (PathFileExists(tchTmp)) {
lstrcpy(lpFileArg, tchTmp);
} else {
if (SearchPath(NULL, lpFileArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) {
lstrcpy(lpFileArg, tchTmp);
}
}
} else if (SearchPath(NULL, lpFileArg, NULL, COUNTOF(tchTmp), tchTmp, NULL)) {
lstrcpy(lpFileArg, tchTmp);
}

Expand Down

0 comments on commit 2b42c80

Please sign in to comment.