@volter/supercode-terminal 0.2.41 → 0.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/substrate/tmux.js +26 -7
package/package.json
CHANGED
package/substrate/tmux.js
CHANGED
|
@@ -75,16 +75,29 @@ export async function createSession({ command, cwd, env, name, owner, ownerOptio
|
|
|
75
75
|
startArgs.push("-c", cwd);
|
|
76
76
|
}
|
|
77
77
|
startArgs.push(...paneBootstrapArgs(0));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
// The session's own options ride the SAME invocation as its creation. A
|
|
79
|
+
// program that exits at once (a name not on PATH) otherwise takes the
|
|
80
|
+
// session with it before `remain-on-exit` or the owner stamp is set, and
|
|
81
|
+
// the next set-option's "no such session" replaces the program's own
|
|
82
|
+
// failure in what the launcher reports.
|
|
83
|
+
const setOnCreate = (option, value) => {
|
|
84
|
+
assertOptionValue(value);
|
|
85
|
+
// tmux splits commands at an argument that ends in `;`.
|
|
86
|
+
if (value.endsWith(";"))
|
|
87
|
+
throw new Error(`A tmux option value set at creation cannot end in ";": ${option}`);
|
|
88
|
+
startArgs.push(";", "set-option", "-t", name, option, value);
|
|
89
|
+
};
|
|
90
|
+
if (owner)
|
|
91
|
+
setOnCreate(ownershipOption, owner);
|
|
82
92
|
for (const [option, value] of Object.entries(sessionOptions).sort(([left], [right]) => left.localeCompare(right))) {
|
|
83
|
-
|
|
93
|
+
assertUserOption(option);
|
|
94
|
+
setOnCreate(option, value);
|
|
84
95
|
}
|
|
85
96
|
for (const [option, value] of Object.entries(settings).sort(([left], [right]) => left.localeCompare(right))) {
|
|
86
|
-
|
|
97
|
+
assertSettingName(option);
|
|
98
|
+
setOnCreate(option, value);
|
|
87
99
|
}
|
|
100
|
+
await runTmuxSessionCreateAsync(startArgs, { cwd, operation: "create tmux session", session: name, socket });
|
|
88
101
|
await declareSessionColorEnvironmentAsync(socket);
|
|
89
102
|
const target = targetForSession(name);
|
|
90
103
|
for (let i = 1; i < panes; i += 1) {
|
|
@@ -150,11 +163,17 @@ export async function sessionOptionValuesAsync(option, socket) {
|
|
|
150
163
|
export async function setSessionSettingAsync(session, option, value, socket) {
|
|
151
164
|
if (!session)
|
|
152
165
|
throw new Error("A session name is required.");
|
|
166
|
+
assertSettingName(option);
|
|
167
|
+
assertOptionValue(value);
|
|
168
|
+
await runAsync("tmux", tmuxArgs(socket, ["set-option", "-t", session, option, value]));
|
|
169
|
+
}
|
|
170
|
+
function assertSettingName(option) {
|
|
153
171
|
if (!/^[a-z][a-z0-9-]*$/.test(option))
|
|
154
172
|
throw new Error(`Not a tmux session option name: ${option}`);
|
|
173
|
+
}
|
|
174
|
+
function assertOptionValue(value) {
|
|
155
175
|
if (/\0|\t|\r|\n/.test(value))
|
|
156
176
|
throw new Error("A tmux option value cannot contain control separators.");
|
|
157
|
-
await runAsync("tmux", tmuxArgs(socket, ["set-option", "-t", session, option, value]));
|
|
158
177
|
}
|
|
159
178
|
/** Set one session-scoped user option without exposing it in the session name. */
|
|
160
179
|
export async function setSessionOptionAsync(session, option, value, socket) {
|