mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Fix for config.session being ignored (#3367)
This commit is contained in:
parent
36eac99902
commit
cba4c66a4b
1 changed files with 30 additions and 28 deletions
|
|
@ -85,19 +85,33 @@ module.exports = class Window {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function createSession(options) {
|
function createSession(extraOptions = {}) {
|
||||||
const uid = uuid.v4();
|
const uid = uuid.v4();
|
||||||
const session = new Session(Object.assign({}, options, {uid}));
|
|
||||||
|
const options = Object.assign(
|
||||||
|
{
|
||||||
|
rows: 40,
|
||||||
|
cols: 100,
|
||||||
|
cwd: process.argv[1] && isAbsolute(process.argv[1]) ? process.argv[1] : cfgDir,
|
||||||
|
splitDirection: undefined,
|
||||||
|
shell: cfg.shell,
|
||||||
|
shellArgs: cfg.shellArgs && Array.from(cfg.shellArgs)
|
||||||
|
},
|
||||||
|
extraOptions,
|
||||||
|
{uid}
|
||||||
|
);
|
||||||
|
|
||||||
|
const session = new Session(options);
|
||||||
sessions.set(uid, session);
|
sessions.set(uid, session);
|
||||||
return {uid, session};
|
return {session, options};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optimistically create the initial session so that when the window sends
|
// Optimistically create the initial session so that when the window sends
|
||||||
// the first "new" IPC message, there's a session already warmed up.
|
// the first "new" IPC message, there's a session already warmed up.
|
||||||
function createInitialSession() {
|
function createInitialSession() {
|
||||||
let {session, uid} = createSession({});
|
let {session, options} = createSession();
|
||||||
const initialEvents = [];
|
const initialEvents = [];
|
||||||
const handleData = data => initialEvents.push(['session data', uid + data]);
|
const handleData = data => initialEvents.push(['session data', options.uid + data]);
|
||||||
const handleExit = () => initialEvents.push(['session exit']);
|
const handleExit = () => initialEvents.push(['session exit']);
|
||||||
session.on('data', handleData);
|
session.on('data', handleData);
|
||||||
session.on('exit', handleExit);
|
session.on('exit', handleExit);
|
||||||
|
|
@ -109,31 +123,19 @@ module.exports = class Window {
|
||||||
session.removeListener('data', handleData);
|
session.removeListener('data', handleData);
|
||||||
session.removeListener('exit', handleExit);
|
session.removeListener('exit', handleExit);
|
||||||
}
|
}
|
||||||
return {session, uid, flushEvents};
|
return {session, options, flushEvents};
|
||||||
}
|
}
|
||||||
let initialSession = createInitialSession();
|
let initialSession = createInitialSession();
|
||||||
|
|
||||||
rpc.on('new', options => {
|
rpc.on('new', extraOptions => {
|
||||||
const sessionOpts = Object.assign(
|
const {session, options} = initialSession || createSession(extraOptions);
|
||||||
{
|
|
||||||
rows: 40,
|
|
||||||
cols: 100,
|
|
||||||
cwd: process.argv[1] && isAbsolute(process.argv[1]) ? process.argv[1] : cfgDir,
|
|
||||||
splitDirection: undefined,
|
|
||||||
shell: cfg.shell,
|
|
||||||
shellArgs: cfg.shellArgs && Array.from(cfg.shellArgs)
|
|
||||||
},
|
|
||||||
options
|
|
||||||
);
|
|
||||||
|
|
||||||
const {uid, session} = initialSession || createSession();
|
sessions.set(options.uid, session);
|
||||||
|
|
||||||
sessions.set(uid, session);
|
|
||||||
rpc.emit('session add', {
|
rpc.emit('session add', {
|
||||||
rows: sessionOpts.rows,
|
rows: options.rows,
|
||||||
cols: sessionOpts.cols,
|
cols: options.cols,
|
||||||
uid,
|
uid: options.uid,
|
||||||
splitDirection: sessionOpts.splitDirection,
|
splitDirection: options.splitDirection,
|
||||||
shell: session.shell,
|
shell: session.shell,
|
||||||
pid: session.pty.pid
|
pid: session.pty.pid
|
||||||
});
|
});
|
||||||
|
|
@ -146,12 +148,12 @@ module.exports = class Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
session.on('data', data => {
|
session.on('data', data => {
|
||||||
rpc.emit('session data', uid + data);
|
rpc.emit('session data', options.uid + data);
|
||||||
});
|
});
|
||||||
|
|
||||||
session.on('exit', () => {
|
session.on('exit', () => {
|
||||||
rpc.emit('session exit', {uid});
|
rpc.emit('session exit', {uid: options.uid});
|
||||||
sessions.delete(uid);
|
sessions.delete(options.uid);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue