Skip to content

Commit

Permalink
Expand environment variables when open file or folder, issue #868.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Sep 25, 2024
1 parent c547da6 commit d890bcd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/Edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ LPWSTR EditURLEncodeSelection(int *pcchEscaped) noexcept {
DWORD cchEscapedW = static_cast<DWORD>(NP2HeapSize(pszEscapedW) / sizeof(WCHAR));
UrlEscape(pszTextW, pszEscapedW, &cchEscapedW, URL_ESCAPE_AS_UTF8);
if (!IsWin7AndAbove()) {
// TODO: encode some URL parts as UTF-8 then percent-escape these UTF-8 bytes.
// TODO: encode some URL parts as UTF-8 then percent escape these UTF-8 bytes.
//ParseURL(pszEscapedW, &ppu);
}

Expand Down Expand Up @@ -7023,14 +7023,21 @@ char *EditGetStringAroundCaret(LPCSTR delimiters) noexcept {

extern bool bOpenFolderWithMatepath;

static DWORD EditOpenSelectionCheckFile(LPCWSTR link, LPWSTR path, int cchFilePath, LPWSTR wchDirectory) noexcept {
static DWORD EditOpenSelectionCheckFile(LPWSTR link, LPWSTR path, int cchFilePath, LPWSTR wchDirectory) noexcept {
if (StrStartsWith(link, L"//")) {
// issue #454, treat as link
lstrcpy(path, L"http:");
lstrcpy(path + CSTRLEN(L"http:"), link);
return 0;
}

// handle variables expanded into absolute path, avoid touch percent encoded URL
if (link[0] == '%') {
if (ExpandEnvironmentStrings(link, wchDirectory, MAX_PATH)) {
lstrcpy(link, wchDirectory);
}
}

DWORD dwAttributes = GetFileAttributes(link);
if (dwAttributes == INVALID_FILE_ATTRIBUTES) {
if (StrNotEmpty(szCurFile)) {
Expand Down
1 change: 0 additions & 1 deletion src/Notepad4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,6 @@ void MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) noexcept {
IDM_EDIT_FIND,
IDM_EDIT_FINDMATCHINGBRACE,
IDM_EDIT_FINDNEXT,
IDM_EDIT_FINDNEXT,
IDM_EDIT_FINDPREV,
IDM_EDIT_GOTOLINE,
IDM_EDIT_GOTO_BLOCK_END,
Expand Down

0 comments on commit d890bcd

Please sign in to comment.