mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
Merge pull request #2714 from RaiKoHoff/Dev_NewFeatures
Try to fix (hardly reproducible) copy Hyperlink issue (#2202)
This commit is contained in:
commit
3847799fde
15
src/Edit.c
15
src/Edit.c
@ -1736,21 +1736,22 @@ void EditURLEncode()
|
||||
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
DocPos const iAnchorPos = SciCall_GetAnchor();
|
||||
DocPos const iSelSize = SciCall_GetSelText(NULL);
|
||||
DocPos const iSelSize = SciCall_GetSelText(NULL) - 1;
|
||||
|
||||
const char* pszText = (const char*)SciCall_GetRangePointer(min_p(iCurPos, iAnchorPos), iSelSize);
|
||||
const char* const pszText = (const char*)SciCall_GetRangePointer(min_p(iCurPos, iAnchorPos), iSelSize);
|
||||
|
||||
WCHAR szTextW[INTERNET_MAX_URL_LENGTH+1];
|
||||
ptrdiff_t const cchTextW = MultiByteToWideCharEx(Encoding_SciCP, 0, pszText, (iSelSize-1), szTextW, INTERNET_MAX_URL_LENGTH);
|
||||
ptrdiff_t const cchTextW = MultiByteToWideChar(Encoding_SciCP, 0, pszText, (int)iSelSize, szTextW, INTERNET_MAX_URL_LENGTH);
|
||||
szTextW[cchTextW] = L'\0';
|
||||
StrTrimW(szTextW, L" \r\n\t");
|
||||
|
||||
size_t const cchEscaped = iSelSize * 3;
|
||||
size_t const cchEscaped = iSelSize * 3 + 1;
|
||||
char* pszEscaped = (char*)AllocMem(cchEscaped, HEAP_ZERO_MEMORY);
|
||||
if (pszEscaped == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
LPWSTR pszEscapedW = (LPWSTR)AllocMem(cchEscaped * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
LPWSTR const pszEscapedW = (LPWSTR)AllocMem(cchEscaped * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
if (pszEscapedW == NULL) {
|
||||
FreeMem(pszEscaped);
|
||||
return;
|
||||
@ -1760,8 +1761,8 @@ void EditURLEncode()
|
||||
|
||||
UrlEscapeEx(szTextW, pszEscapedW, &cchEscapedW, true);
|
||||
|
||||
ptrdiff_t const cchEscapedEnc = WideCharToMultiByteEx(Encoding_SciCP, 0, pszEscapedW, cchEscapedW,
|
||||
pszEscaped, cchEscaped, NULL, NULL);
|
||||
ptrdiff_t const cchEscapedEnc = WideCharToMultiByte(Encoding_SciCP, 0, pszEscapedW, cchEscapedW,
|
||||
pszEscaped, (int)cchEscaped, NULL, NULL);
|
||||
|
||||
DocPos const saveTargetBeg = SciCall_GetTargetStart();
|
||||
DocPos const saveTargetEnd = SciCall_GetTargetEnd();
|
||||
|
||||
@ -3511,7 +3511,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
} else if (fvm_mode == (FVMM_MARGIN | FVMM_FOLD)) {
|
||||
i = IDM_VIEW_FV_BKMRKFOLD;
|
||||
} else if (fvm_mode == (FVMM_LN_BACKGR | FVMM_FOLD)) {
|
||||
i = IDM_VIEW_FV_HIGHLIGHT;
|
||||
i = IDM_VIEW_FV_HIGHLGFOLD;
|
||||
} else {
|
||||
i = IDM_VIEW_FV_FOLD;
|
||||
}
|
||||
@ -6871,8 +6871,9 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio
|
||||
const char* pszText = (const char*)SciCall_GetRangePointer(firstPos, length);
|
||||
|
||||
WCHAR szTextW[INTERNET_MAX_URL_LENGTH + 1];
|
||||
ptrdiff_t const cchTextW = MultiByteToWideCharEx(Encoding_SciCP, 0, pszText, length, szTextW, COUNTOF(szTextW));
|
||||
ptrdiff_t const cchTextW = MultiByteToWideChar(Encoding_SciCP, 0, pszText, (int)length, szTextW, COUNTOF(szTextW));
|
||||
szTextW[cchTextW] = L'\0';
|
||||
StrTrimW(szTextW, L" \r\n\t");
|
||||
|
||||
const WCHAR* chkPreFix = L"file://";
|
||||
|
||||
@ -6887,8 +6888,8 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio
|
||||
DWORD cchEscapedW = (DWORD)(length * 3);
|
||||
LPWSTR pszEscapedW = (LPWSTR)AllocMem(cchEscapedW * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
if (pszEscapedW) {
|
||||
DWORD const flags = (DWORD)(URL_BROWSER_MODE | URL_ESCAPE_AS_UTF8);
|
||||
UrlEscape(szTextW, pszEscapedW, &cchEscapedW, flags);
|
||||
//~UrlEscape(szTextW, pszEscapedW, &cchEscapedW, (URL_BROWSER_MODE | URL_ESCAPE_AS_UTF8));
|
||||
UrlEscapeEx(szTextW, pszEscapedW, &cchEscapedW, false);
|
||||
SetClipboardTextW(Globals.hwndMain, pszEscapedW, cchEscapedW);
|
||||
FreeMem(pszEscapedW);
|
||||
bHandled = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user