Handle Unicode Windows profile paths in editor settings (by Codex)
This commit is contained in:
1 parent
b199f67eec
commit
ef111342f9
3 files changed
+31
-3
No files matched your search
@@ -24,6 +24,7 @@ Validation performed:
|
|||||||
references, dates/scales, roster moves/swaps/order, shared undo/redo/save
|
references, dates/scales, roster moves/swaps/order, shared undo/redo/save
|
||||||
checkpoint, atomic OBW overwrite, exact image originals, arbitrary SVG/raster
|
checkpoint, atomic OBW overwrite, exact image originals, arbitrary SVG/raster
|
||||||
transforms, unknown-extension preservation and authenticated MCP HTTP.
|
transforms, unknown-extension preservation and authenticated MCP HTTP.
|
||||||
|
Windows additionally checks a profile directory containing non-ASCII letters.
|
||||||
- `tests/editor_gui_smoke.py`: real mouse/keyboard inspector edit; untouched
|
- `tests/editor_gui_smoke.py`: real mouse/keyboard inspector edit; untouched
|
||||||
JSON colour field retained; native search focus; shared MCP/native undo/redo;
|
JSON colour field retained; native search focus; shared MCP/native undo/redo;
|
||||||
save to OBW. This check caught and fixed RmlUI textarea entity handling and
|
save to OBW. This check caught and fixed RmlUI textarea entity handling and
|
||||||
|
|||||||
+10
-3
@@ -3,7 +3,10 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <random>
|
#include <random>
|
||||||
#ifndef _WIN32
|
#ifdef _WIN32
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
namespace bmh::editor {
|
namespace bmh::editor {
|
||||||
@@ -11,8 +14,12 @@ Options Options::load(fs::path override_path) {
|
|||||||
Options result;
|
Options result;
|
||||||
if (override_path.empty()) {
|
if (override_path.empty()) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
auto base = std::getenv("APPDATA");
|
// The narrow CRT environment is encoded in the active Windows code
|
||||||
override_path = (base ? path(base) : fs::temp_directory_path()) / "OpenBMH" / "editor.json";
|
// page, not UTF-8. Use the native path for names such as Müller.
|
||||||
|
wchar_t base[32768]{};
|
||||||
|
const auto count = GetEnvironmentVariableW(L"APPDATA", base, 32768);
|
||||||
|
override_path =
|
||||||
|
(count > 0 && count < 32768 ? fs::path(base) : fs::temp_directory_path()) / "OpenBMH" / "editor.json";
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
auto base = std::getenv("HOME");
|
auto base = std::getenv("HOME");
|
||||||
override_path =
|
override_path =
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include <httplib.h>
|
#include <httplib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace bmh::editor;
|
using namespace bmh::editor;
|
||||||
namespace {
|
namespace {
|
||||||
@@ -175,6 +179,22 @@ int main() {
|
|||||||
options.apply({{"language", "en"}, {"theme", "silver"}, {"mcp_port", 0}});
|
options.apply({{"language", "en"}, {"theme", "silver"}, {"mcp_port", 0}});
|
||||||
options.save();
|
options.save();
|
||||||
check(Options::load(root / "settings.json").language == "en", "persistent language");
|
check(Options::load(root / "settings.json").language == "en", "persistent language");
|
||||||
|
#ifdef _WIN32
|
||||||
|
{
|
||||||
|
wchar_t old_value[32768]{};
|
||||||
|
const auto length = GetEnvironmentVariableW(L"APPDATA", old_value, 32768);
|
||||||
|
struct Restore {
|
||||||
|
std::wstring value;
|
||||||
|
bool present;
|
||||||
|
~Restore() { SetEnvironmentVariableW(L"APPDATA", present ? value.c_str() : nullptr); }
|
||||||
|
} restore{old_value, length > 0};
|
||||||
|
const auto profile = root / L"Profil-ÄÖÜ";
|
||||||
|
SetEnvironmentVariableW(L"APPDATA", profile.c_str());
|
||||||
|
const auto native_options = Options::load();
|
||||||
|
check(native_options.settings_file == profile / "OpenBMH/editor.json", "Unicode Windows profile path");
|
||||||
|
check(fs::is_regular_file(native_options.settings_file), "Unicode Windows settings saved");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
check(tr("de", "clubs") != tr("en", "clubs"), "bilingual labels");
|
check(tr("de", "clubs") != tr("en", "clubs"), "bilingual labels");
|
||||||
McpServer mcp(s);
|
McpServer mcp(s);
|
||||||
mcp.start(options);
|
mcp.start(options);
|
||||||
|
|||||||
Reference in new issue
Block a user