mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18: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 useConpty = config.getConfig().useConpty;
|
||||
|
||||
// Max duration to batch session data before sending it to the renderer process.
|
||||
const BATCH_DURATION_MS = 16;
|
||||
|
|
@ -107,13 +108,20 @@ module.exports = class Session extends EventEmitter {
|
|||
|
||||
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 {
|
||||
this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, {
|
||||
cols: columns,
|
||||
rows,
|
||||
cwd,
|
||||
env: getDecoratedEnv(baseEnv)
|
||||
});
|
||||
this.pty = spawn(shell || defaultShell, shellArgs || defaultShellArgs, options);
|
||||
} catch (err) {
|
||||
if (/is not a function/.test(err.message)) {
|
||||
throw createNodePtyError();
|
||||
|
|
|
|||
|
|
@ -123,12 +123,13 @@ module.exports = class Window {
|
|||
|
||||
// Optimistically create the initial session so that when the window sends
|
||||
// the first "new" IPC message, there's a session already warmed up.
|
||||
let initialSession = null;
|
||||
function createInitialSession() {
|
||||
let {session, options} = createSession();
|
||||
const initialEvents = [];
|
||||
const handleData = data => initialEvents.push(['session data', data]);
|
||||
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('exit', handleExit);
|
||||
initialSession = null;
|
||||
|
|
@ -145,7 +146,7 @@ module.exports = class Window {
|
|||
}
|
||||
return {session, options, flushEvents};
|
||||
}
|
||||
let initialSession = createInitialSession();
|
||||
initialSession = createInitialSession();
|
||||
|
||||
rpc.on('new', extraOptions => {
|
||||
const {session, options} = initialSession || createSession(extraOptions);
|
||||
|
|
|
|||
Loading…
Reference in a new issue