Skip to content

Commit

Permalink
Send the client screen size to the terminal server
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Zatsarynnyi <azatsary@redhat.com>
  • Loading branch information
azatsarynnyy committed Jun 16, 2022
1 parent 27f00c5 commit d24aef5
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions code/src/vs/server/node/che/remoteTerminalMachineExecChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ export class RemoteTerminalMachineExecChannel implements IServerChannel<RemoteAg
cmd: commandLine,
tty: true,
cwd: machineExecCwd,
cols: args.cols,
rows: args.rows
};

const jsonCommand = {
Expand All @@ -260,6 +262,27 @@ export class RemoteTerminalMachineExecChannel implements IServerChannel<RemoteAg
return createProcessResult;
}

if (command === '$resize') {
const resizeTerminalMachineExecCall = {
id: args[0],
cols: args[1],
rows: args[2]
};

const jsonCommand = {
jsonrpc: '2.0',
method: 'resize',
params: resizeTerminalMachineExecCall,
id: -1
};

if (this.machineExecWebSocket) {
this.machineExecWebSocket.send(JSON.stringify(jsonCommand));
}

return undefined;
}

this.logService.error(`RemoteTerminalChannel: unsupported command/${command}`);
return {};
}
Expand Down Expand Up @@ -376,19 +399,22 @@ export class ReconnectingWebSocket {
return;
}

// connect to the embedded machine-exec
const wsTerminal = new WS(`ws://localhost:3333/attach/${message.result}`);
// machine-exec responds a number of the created terminal session
if (Number.isFinite(message.result)) {
// connect to the embedded machine-exec
const wsTerminal = new WS(`ws://localhost:3333/attach/${message.result}`);

this.terminalIds.set(message.result, message.id);
this.terminals.set(message.id, wsTerminal);
this.terminalIds.set(message.result, message.id);
this.terminals.set(message.id, wsTerminal);

// the shell is ready
this.onProcessReady.fire({ id: message.id, event: { pid: message.id, cwd: '' } });
// the shell is ready
this.onProcessReady.fire({ id: message.id, event: { pid: message.id, cwd: '' } });

// redirect everything to the client
wsTerminal.on('message', (data: WS.Data) => {
this.onProcessData.fire({ id: message.id, event: data.toString() });
});
// redirect everything to the client
wsTerminal.on('message', (data: WS.Data) => {
this.onProcessData.fire({ id: message.id, event: data.toString() });
});
}
} catch (e) {
console.error('Unable to parse result', e);
}
Expand Down

0 comments on commit d24aef5

Please sign in to comment.