mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
support config 'useConpty'
This commit is contained in:
parent
b890cc23d1
commit
67a1fc4dbb
2 changed files with 17 additions and 8 deletions
|
|
@ -20,6 +20,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
const envFromConfig = config.getConfig().env || {};
|
const envFromConfig = config.getConfig().env || {};
|
||||||
|
const useConpty = config.getConfig().useConpty;
|
||||||
|
|
||||||
// Max duration to batch session data before sending it to the renderer process.
|
// Max duration to batch session data before sending it to the renderer process.
|
||||||
const BATCH_DURATION_MS = 16;
|
const BATCH_DURATION_MS = 16;
|
||||||
|
|
@ -107,13 +108,20 @@ module.exports = class Session extends EventEmitter {
|
||||||
|
|
||||||
const defaultShellArgs = ['--login'];
|
const defaultShellArgs = ['--login'];
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
cols: columns,
|
||||||
|
rows,
|
||||||
|
cwd,
|
||||||
|
env: getDecoratedEnv(baseEnv)
|
||||||
|
};
|
||||||
|
|
||||||
|
// if config do not set the useConpty, it will be judged by the node-pty
|
||||||
|
if (typeof useConpty === 'boolean') {
|
||||||
|
options.experimentalUseConpty = useConpty;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, {
|
this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, options);
|
||||||
cols: columns,
|
|
||||||
rows,
|
|
||||||
cwd,
|
|
||||||
env: getDecoratedEnv(baseEnv)
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (/is not a function/.test(err.message)) {
|
if (/is not a function/.test(err.message)) {
|
||||||
throw createNodePtyError();
|
throw createNodePtyError();
|
||||||
|
|
|
||||||
|
|
@ -123,12 +123,13 @@ module.exports = class Window {
|
||||||
|
|
||||||
// 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.
|
||||||
|
let initialSession = null;
|
||||||
function createInitialSession() {
|
function createInitialSession() {
|
||||||
let {session, options} = createSession();
|
let {session, options} = createSession();
|
||||||
const initialEvents = [];
|
const initialEvents = [];
|
||||||
const handleData = data => initialEvents.push(['session data', data]);
|
const handleData = data => initialEvents.push(['session data', data]);
|
||||||
const handleExit = () => {
|
const handleExit = () => {
|
||||||
// the warmed up session exits when open hyper by cli.
|
// the warmed up session should be cleaned if exit before add a new session.
|
||||||
session.removeListener('data', handleData);
|
session.removeListener('data', handleData);
|
||||||
session.removeListener('exit', handleExit);
|
session.removeListener('exit', handleExit);
|
||||||
initialSession = null;
|
initialSession = null;
|
||||||
|
|
@ -145,7 +146,7 @@ module.exports = class Window {
|
||||||
}
|
}
|
||||||
return {session, options, flushEvents};
|
return {session, options, flushEvents};
|
||||||
}
|
}
|
||||||
let initialSession = createInitialSession();
|
initialSession = createInitialSession();
|
||||||
|
|
||||||
rpc.on('new', extraOptions => {
|
rpc.on('new', extraOptions => {
|
||||||
const {session, options} = initialSession || createSession(extraOptions);
|
const {session, options} = initialSession || createSession(extraOptions);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue