Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Point the toggle agreement test at the new %command% write, trim a trailing separator

Logan614d4553c2b9
diff --git a/app/Tests/NotProtonAppTests/ToggleAgreementTests.swift b/app/Tests/NotProtonAppTests/ToggleAgreementTests.swift
index 5d24830..adcff89 100644
--- a/app/Tests/NotProtonAppTests/ToggleAgreementTests.swift
+++ b/app/Tests/NotProtonAppTests/ToggleAgreementTests.swift
@@ -40,7 +40,7 @@ struct ToggleAgreementTests {
#expect(names.count >= 8, "found \(names.count) toggles, the parse looks wrong")
#expect(
- webpatch.contains(#"v.push(\"%command%\")"#),
+ webpatch.contains(#"rest=\"%command%\""#),
"webpatch.c no longer writes %command%, so the toggles would reach the game as arguments"
)
diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.c
index 7a04ff7..4eb30c7 100644
--- a/dylib/feats/webpatch.c
+++ b/dylib/feats/webpatch.c
@@ -146,7 +146,7 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {
"s=ps=>{if(!a)return;let rest=\"\",end=0;" \
"ed.forEach(x=>{if(ps.some(p=>o.startsWith(p[0]+\"=\",x.start))){" \
"rest+=o.slice(end,x.start);end=x.end;" \
- "while(end<o.length&&/\\s/.test(o[end]))end++}});rest+=o.slice(end);" \
+ "while(end<o.length&&/\\s/.test(o[end]))end++}});rest=end<o.length?rest+o.slice(end):rest.trimEnd();" \
"const added=ps.filter(p=>p[1]).map(p=>p[0]+\"=\"+p[1]).join(\" \");" \
"if(added&&cut<0)rest=\"%command%\"+(rest?\" \"+rest:\"\");" \
"const r=added?added+(rest?\" \"+rest:\"\"):rest;" \
diff --git a/dylib/tests/panel-behavior/launch-options.js b/dylib/tests/panel-behavior/launch-options.js
index 91519c6..65234e7 100644
--- a/dylib/tests/panel-behavior/launch-options.js
+++ b/dylib/tests/panel-behavior/launch-options.js
@@ -55,6 +55,9 @@ for (const form of Object.keys(FORMS)) {
t.ok(repeated === 'MTL_HUD_ENABLED=1 %command%',
'repeated edits do not accumulate whitespace');
}
+ written.length = 0;
+ hud('WINEDEBUG=x MTL_HUD_ENABLED=1').props.onChange(false);
+ t.ok(last() === 'WINEDEBUG=x', 'removing the last token leaves no trailing separator');
const duplicates = 'MTL_HUD_ENABLED=1\tMTL_HUD_ENABLED="0" %command%';
t.ok(!hud(duplicates).props.checked, 'the last assignment determines the toggle');