Skip to content

Commit 552675c

Browse files
committed
lift 4096 character limit when importing repositories from user input
1 parent f340af9 commit 552675c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/win32.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
# define widen_cstr(cstr) cstr
2525
#endif
2626

27+
#include <vector>
28+
2729
#ifdef _WIN32
2830
std::wstring Win32::widen(const char *input, const UINT codepage)
2931
{
@@ -55,10 +57,16 @@ int Win32::messageBox(const HWND handle, const char *text,
5557

5658
std::string Win32::getWindowText(const HWND handle)
5759
{
58-
char_type buffer[4096];
59-
GetWindowText(handle, buffer, static_cast<int>(std::size(buffer)));
60+
int buffer_len = GetWindowTextLength(handle);
61+
if(buffer_len)
62+
++buffer_len; // null terminator
63+
else // REAPER <6.09 on non-Windows, before SWELL a34caf91
64+
buffer_len = 8192;
6065

61-
return narrow(buffer);
66+
std::vector<char_type> buffer(buffer_len, 0);
67+
GetWindowText(handle, buffer.data(), buffer_len);
68+
69+
return narrow(buffer.data());
6270
}
6371

6472
void Win32::setWindowText(const HWND handle, const char *text)

0 commit comments

Comments
 (0)